Hello everybody, today I'm gonna describe a bit of SQL language for a dummy. (If you don't know why I always put words "Om Swastiastu" and "Om Santhi, Santhi, Santhi, Om" in every first and last line of my post, here I tell you. "Om Swastiastu" is a greeting words for Hinduism in Bali, and "Om Santhi, Santhi, Santhi, Om" is a farewell words for Hinduism in Bali. Try to visit Bali, you will be able to find words like that). Okay, back to the topic. I will start from the SQL function.
Data Definition Language
- Command to create database object such as tables, indexes and view.
- Command to define access right to those database objects.
Includes commands to:
- and retrieve data within the database tables.
- SQL CREATE TABLE
- Used to describe Layout of tables
- Typical restrictions placed by DBMS
- Names cannot exceed 18 characters
- Names must start with a letter
- Names can contain only letter, numbers and underscore ( _ )
- Names cannot contain spaces
Typical Data Types
- Numbers without a decimal point
- Uses less spaces than INTEGER
- P = number of digits, Q = number of decimal places
- Character string, N = places long
- Dates in DD-MON-YYYY or MM/DD/YYYY
- Data type selection is usually dictated by the nature of the data and by the intended use
- Pay close attention to the expected use of attributes for sorting and data retrieval purposes
- NOT NULL constraint
- Ensures that a column does not accept nulls
- UNIQUE constraint
- Ensures that all values in a column are unique
- Equal to ( = )
- Less than ( < )
- Less than or equal to ( <= )
- Greater than ( > )
- Greater than or equal to ( >= )
- Not equal to (<>) or ( != )
- Used to check whether attribute value is within a range
- IS NULL
- Used to check whether attribute value is null
- Used to check whether attribute value matches a given string pattern
- Used to check whether attribute value matches any value within a value list
- A computed fields is a fields not physically stored in the Database.
- Can use +, -, * and /
- Clause SQL: ORDER BY
- Always listed last in the SELECT command sequence.
- ASC (by default) or DESC (to specify to sort from the highest value to the lowest one)
Some Basic SQL Aggregate Function
- COUNT (the number of rows containing "non null" values)
- MIN (the minimum attribute value encountered in a given column)
- MAX (the maximum attribute value encountered in a given column)
- SUM (the sum of all column for a given column)
- AVG (the arithmetic means (average) for the specified column)
GROUP BY allows the 'grouping' of record to determine the average, sum, count, min or max.
Okay, that's all I can tell about the Introduction of SQL. Hope you like it. If there's any critical or suggestion, please write in the box below. Thank you very much.
"Om Santhi, Santhi, Santhi, Om"