DDL Statements define, modify and destroy the structure of database objects such as tables, indexes and views as well as the database itself. The CREATE, ALTER, and DROP statements are included under this category.
CREATE
Used to create database or its objects
DROP
Used to delete/remove objects from a database
ALTER
Used to modifies the structure of a table
DataManipulationLanguage (DML)
DML Statements are used to manipulate the contents of a database by allowing insertion, deletion, modification and retrieval of the contents of tables. Common DML statements are SELECT, INSERT, UPDATE, and DELETE.
INSERT INTO
Used to insert new data into a table
SELECT
Retrieves data from a table
UPDATE
Modifies data stored in tables
DELETE
Removes a row/records from a table
Data Control Language (DCL)
DCL Statements are used to control a database, including committing data and administering privileges by authorizing certain users to view, change, or delete database objects and/or data in it.
GRANT
Gives user's access privileges to database
REVOKE
Withdraw user's access privileges given by using the GRANT command
Comment
A word, clause or statement added by the programmer to remind him of what a particular part of code does. Comments are ignored by the compiler.
Single line comment
Two consecutive hyphens is used
Multiple line comment
Backslash asterisk is used. Anything inside the /* and */ is ignored by the compiler.
Identifiers
Names given to database objects such as tables, columns, views, databases and servers
Keywords
Words with special meanings in SQL therefore are considered reserved and cannot be used as identifiers
SQL Statement
A grammatically acceptable and valid combination of indivisible parts (keywords, identifiers, operators, punctuation marks, literals or constraints) of the SQL language
Clause
A fragment of an SQL statement that is usually introduced by a keyword. The order of the clauses in an SQL statement is very important to produce grammatically correct SQL statement. A clause may be required or optional.
Expression
Any legal combination of keywords and numeric symbols that evaluates to a single data value
Functions
Sections of code that take zero, one, or more input values, perform a specific assignment and return a scalar or tabular set of values
Operators
Signs or symbols that can perform an operation between operands or between two or more than two expressions
Semicolon
Used to end SQL statements. In some variants of SQL (such as in MS SQL) semicolon is optional.
Data Type
Defines what type of data can be contained by a column, and what kind of operation can be performed on the data or values stored. It is an attribute that specifies the type of data of any object.
CHAR
Holds a fixed length combination of letters, numbers and special characters. The size parameter specifies the column length in characters can be from 0 to 255.
VARCHAR
Holds VARIABLE length string (can contain letters, numbers, and special characters). The size parameter specifies the maximum column length in characters - can be from 0 to 65535.
BLOB
Binary Large Objects, it holds and stores large objects such as text documents, images or videos. Holds up to 65,535 bytes of data.
TINYINT
A very small integer. Signed range is from -128 to 127. Unsigned range is from 0 to 255.
SMALLINT
A small integer. Signed range is from -32768 to 32767. Unsigned range is from 0 to 65535.
INT
A medium integer. Signed range is from -2147483648 to 2147483647. Unsigned range is from 0 to 4294967295.
BIGINT
A large integer. Signed range is from -9223372036854775808 to 9223372036854775807. Unsigned range is from 0 to 18446744073709551615.
FLOAT(size,d)
A floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter.
DOUBLE(size,d)
A normal-size floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter.
DECIMAL(size,d)
An exact fixed-point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. The maximum number for size is 65. The maximum number for d is 30. The default value for size is 10. The default value for d is 0.
DATE
Holds date value in the format: YYYY-MM-DD. The supported range is from '1000-01-01' to '9999-12-31'
DATETIME
Holds a date and time combination in the format: YYYY-MM-DD hh:mm:ss. The supported range is from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'
CREATE DATABASE
Used to create a new SQL database
USE DATABASE
Used to switch from the default database master to preferred database