Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3
SNO Command, Syntax, and Purpose Category
1. Command: CREATE DATABASE DDL
Syntax: CREATE DATABASE <databasename>; Purpose: Creates a database with the specified name.
2. Command: CREATE TABLE DDL
Syntax: CREATE TABLE <tablename> (<column name1> <data type1> [,<column name2> <data type2>, . . <column nameN> <data typeN>] ); Purpose: Creates a table with the specified name.
3. Command: ALTER TABLE DDL
Syntax: ALTER TABLE <tablename> ADD <columnname> <datatype>; ALTER TABLE <tablename> DROP <columnname>; ALTER TABLE <tablename> MODIFY <column> <new_definition>; Purpose: Modifies the structure of a table
4. Command: USE DML
Syntax: USE <databasename>; Purpose: Opens the specified database for use.
5. Command: SELECT DATABASE() DML
Syntax: SELECT DATABASE(); Purpose: Shows the name of the current database
6. Command: SHOW TABLES DML
Syntax: SHOW TABLES; Purpose: Shows a list of tables present in the current database.
7. Command: INSERT DML
Syntax: INSERT INTO <tablename> [<column1>, <column2>, ..., <columnn>] VALUES (<value1>, <value2>, ... <value n>); Purpose: Inserts data into a table SNO Command, Syntax, and Purpose Category
8. Command: SELECT DML
Syntax: SELECT <* / column name / expression> , [<column name/Expression list>] FROM <table name> [WHERE <condition>] [ORDER BY <column name / expression> [ASC/DESC]]; There are multiple ways to use SELECT. These will be explained with the help of examples in this lesson. Purpose: Retrieves data from a table
9. Command: DESCRIBE DML
Syntax: DESC[RIBE] <tablename>; Purpose: Shows the structure of a table.
10. Command: UPDATE DML
Syntax: UPDATE <tablename> SET <column name> = <value> [,<column name> = <value>, …] [WHERE <condn>]; Purpose: Updates/Modifies data in a table
11. Command: DELETE DML
Syntax: DELETE FROM < tablename> [ Where < condition>]; Purpose: Deletes data from a table
12. Command: DROP TABLE DDL
Syntax: DELETE TABLE < tablename> Purpose: Delete the table Following are the clauses which can be used with SELECT command:
a. DISTINCT Used to display distinct values from a column of a table.
b. WHERE Used to specify the condition based on which rows of a table are displayed. c. BETWEEN Used to define the range of values within which the column values must fall to make a condition true. Range includes both the upper and the lower values. d. IN Used to select values that match any value in a list of Specified values. e. LIKE Used for pattern matching of string data using wildcard characters % and _ . f. IS NULL / Used to select rows in which the specified column is NULL (or is NOT NULL NOT NULL) g. ORDER BY Used to display the selected rows in ascending or in descending order of the specified column/expression.