Subject: Class 10, Information Technology
Prepared by: Ms. Anjali Nair
BASIC SQL COMMANDS
COMMAND PURPOSE
SHOW DATABASES; List all databases on the server
USE Database _Name; Switch to a Database
CREATE TABLE Table_name ( Create table with the attribute specifications
Column1 Datatype, Possible Constraints – (PRIMARY KEY,NOT
Column2 Datatype, NULL,FOREIGN KEY)
Column3 Datatype);
DESC Table_name; To see the table description
Or
DESCRIBE Table_name;
INSERT INTO Table_name VALUES To insert a single record into a table
(Value1,Value2,Value3);
INSERT INTO Table_name(Column1,Column2) To insert multiple records into a table
VALUES (Value1, Value2),(Value3,Value4);
SELECT *FROM Table_name; To retrieve and display all the records in a table
SELECT *FROM Table_name WHERE To retrieve and display the record/s which satisfies
Column_name=value; the WHERE condition
SELECT *FROM Table_name ORDER BY To sort the records in ascending or descending order
Column_name ASC/DESC; based on a column
SELECT Column1,Column2 FROM To retrieve and display selected columns from a
Table_name; table.
DELETE FROM Table_name WHERE To delete a record from a table
<CONDITION>;
DROP TABLE Table_name; Delete the entire table
DROP DATABASE Database_Name; To delete a specific database from a server