[go: up one dir, main page]

0% found this document useful (0 votes)
130 views2 pages

SQL Class 10

Uploaded by

gaurav887721
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views2 pages

SQL Class 10

Uploaded by

gaurav887721
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL COMMAND

1. CREATE Used to create a new table in a database.

Syntax: CREATE TABLE table_name ( Column1 datatype, Column2 datatype,…);

Eg:- CREATE TABLE Students ( ID INT, Name VARCHAR(50), Age INT );

2. SELECT:- Used to retrieve data from a table.

FROM Clause: Specifies the table.

WHERE Clause: Filters rows based on conditions.

Syntax: SELECT column1, column2

FROM table_name

WHERE condition;

Example:SELECT Name, Age

FROM Students

WHERE Age > 18;

3. ORDER BY: Sorts the result in ascending (default) or descending order.

Syntax: SELECT column1, column2

FROM table_name

ORDER BY column1 [ASC|DESC];

Example:SELECT Name, Age

FROM Students

ORDER BY Age DESC;

4. INSERT:- Adds new records to a table.

Syntax:INSERT INTO table_name (column1, column2)

VALUES (value1, value2);

Example:INSERT INTO Students (ID, Name, Age) VALUES (1, ‘Alice’, 20);
5. UPDATE:- Modifies existing records in a table.

Syntax:UPDATE table_name

SET column1 = value1

WHERE condition;

Example:UPDATE Students

SET Age = 21

WHERE ID = 1;

6. DELETE:- Removes records from a table.

Syntax:DELETE FROM table_name

WHERE condition;

Example:DELETE FROM Students

WHERE Age < 18;

7. ALTER:- Used to modify the structure of a table (e.g., add or drop columns).

Syntax:ALTER TABLE table_name

ADD column_name datatype;

Example (Add Column): ALTER TABLE Students

ADD Gender VARCHAR(10);

Example (Drop Column): ALTER TABLE Students

DROP COLUMN Gender;

8. DROP:- Deletes an entire table or database.

Syntax:DROP TABLE table_name;

Example:DROP TABLE Students;

You might also like