SQL - Structured Query Language
SQL - Structured Query Language
INSERT
UPDATE
DELETE
MERGE Data Manipulation language
CREATE
ALTER
DROP
RENAME
TRUNCATE Data Definition language (DDL)
COMMIT
ROLLBACK
SAVEPOINT Transaction control
GRANT
REVOKE Data Control language (DCL)
SQL The SELECT Statement
The SELECT statement is used to select data from a table. The
tabular result is stored in a result table (called the result-set).
Syntax
SELECT column_name(s)
FROM table_name
To select the columns named "LastName" and "FirstName", use a
SELECT statement like this:
SELECT LastName, FirstName FROM Persons
Persons
LastName FirstName
Hansen Ola
Svendson Tove
Pettersen Kari
Select All Columns
To create a table:-
Eg.
Eg.
Eg.
Eg.
Select * from student where marks>50 ;
1 row created.
1 row created.
The UPDATE Statement
1 row updated.
• UPDATE student SET rollno = 70 WHERE rollno = 10 ;
All rows in the table are modified if you omit the WHERE
clause.
22 rows updated.
22 rows updated.
The DELETE Statement
DELETE tablename ;
• DELETE student;
22 rows deleted
To delete only selected rows from the table:-
1 row deleted.
3 rows deleted.
• DELETE students WHERE city IN (‘bangalore’, ‘delhi’ );
4 rows deleted.
Dropping a Table
All data and structure in the table is deleted.
Table dropped.
Rename the table
table renamed.
The ALTER TABLE Statement
To add a column :-
table altered.
To modify the column: - ( data type / size / default value)
Table altered.
To drop the column :-
Table altered.