Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
SQL Syntax
1.Create Syntax: Creates a new table in the database.
CREATE TABLE table_name column1 datatype, column2 datatype ...); 2.Insert Syntax: Inserts new records into a table. INSERT INTO table_name (column1, column2) VALUES (value1, value2); 3. Alter syntax: Modifies an existing table. ALTER TABLE table_name ADD column_name datatype; 4.Update syntax: Modifies existing records in a table. UPDATE table_name SET column1 = value1 WHERE condition;
5.Delete Syntax: Deletes records from a table.
DELETE FROM table_name WHERE condition; 6.Drop Syntax: Deletes a table and all its data from the database. DROP TABLE table_name; 7.Select Syntax: Used to retrieve data from a database. SELECT column1, column2 FROM table_name; 8.From: Specifies the table from which to retrieve the data. SELECT column1, column2 FROM table_name; 9.Where: Filters records based on specified conditions. SELECT column1, column2 FROM table_name WHERE condition;
10.GROUP BY: Groups rows that have the same values
into summary rows. SELECT column1, COUNT(*) FROM table_name GROUP BY column1; 11.ORDER BY: Sorts the result set in ascending or descending order. SELECT column1, column2 FROM table_name ORDER BY column1 ASC/Desc; (ASC = Ascending, Desc = Descending)