www.bullraider.com

Types Of SQL Statements

AddThis Social Bookmark Button

Type of Sql Statements

  • DDL(Data Definition Language)CREATE ,ALTER,DROP

CREATE TABLE:     
CREATE TABLE EMP (
EmpNo NUMBER,
EName VarChar(25),
Job Char(10) ,
Hiredate Date,
)
ALTER:
Its used when we want to change the table structure, like adding or dropping a column,adding or dropping constraint
Example:
ALTER TABLE EMP
ADD (DeptNo short);
ALTER TABLE EMP
DROP Hiredate;
DROP:
Drop command delete the table structure which can't be rollback
Example:
DROP TABLE EMP;
 

  • DML(Data Manipulation Language)SELECT,INSERT,UPDATE,DELETE

SELECT EXAMPLE:
SELECT * FROM EMP;
SELECT NAME,JOB FROM EMP;
INSERT EXAMPLE:
INSERT INTO EMP VALUES(1001,'PHILIP','MGR')
UPDATE EXAMPLE:
UPDATE  EMP SET SAL  = 0.5 * SAL
DELETE EXAMPLE:
DELETE * FROM EMP;
DELETE  FROM EMP WHERE DEPT NO=10;

  • DCL(Data Control Language)GRANT,REVOKE,ROLLBACK,COMMIT

GRANT: You can grant users various privileges to tables. These privileges can be any combination of select, insert, update, delete, references, alter, and index
EXAMPLE:
Grant select on SCOTT.EMP to USER1.EMP;
REVOKE:Its opposite to grant. It get  the privileges back.
Revoke select on SCOTT.EMP to USER1.EMP;

  • TCL(Transaction Control Language)

COMMIT:Use the COMMIT statement to end your current transaction and make permanent all changes performed in the transaction
ROLLBACK :Use the ROLLBACK statement to undo work done in the current transaction

SAVEPOINT: It defines breakpoints for a transaction to allow partial rollbacks


Powered by Bullraider.com