Friday 11 October 2013

SQL Quick View


Four Categories


DDL - Data Definition Language - Used to define format and type i.e. structure of objects.

Ex.CREATE, ALTER, DROP, TRUNCATE, COMMENT, RENAME

DML - Data Manipulation Language - Used to manipulate data stored in tables.

Ex.SELECT, INSERT, UPDATE, DELETE, MERGE, CALL, EXPLAIN PLAN, LOCK TABLE

DCL - Data Control Language - Used to define roles, permissions, referential integrities and other security features.

Ex.GRANT, REVOKE

TCL - Transactional Control Language - Used to manage transactions happening in database.

Ex.COMMIT, ROLLBACK, SAVEPOINT, SET TRANSACTION
 
Objects >> General
Tables - Objects which will stay permanently in database. Contains columns and rows.
CREATE TABLE Emp1(ID int Primary Key, FirstName VARCHAR(255), LastName VARCHAR(255), Salary int) CREATE TABLE Emp2(ID int Primary Key, Area VARCHAR(255), Track VARCHAR(255))
Views - Same as tables, but resides dynamically not permanently. But database will have query to make the view permanently.
1.CREATE VIEW V1 2.AS 3.SELECT * FROM EMP1 4. 5.-- Access the View 6.SELECT * FROM V1