ddl & dml final

14
By : Lohit Shetty & Dhanashree Khopkar 

Upload: dhanashreekhopkar

Post on 07-Apr-2018

237 views

Category:

Documents


0 download

TRANSCRIPT

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 1/14

By :

Lohit Shetty &

Dhanashree Khopkar 

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 2/14

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 3/14

DDL

DDL is abbreviation of Data Definition Language.

It is used to create and modify the structure of 

database objects in database.

It is used in a generic sense to refer to any formallanguage for describing data or information structures.

Used for the following :

Creating Databases

Creating Tables Drop tables

Alter tables

For defining primary key & foreign keys

etc....

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 4/14

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 5/14

CREATE statements

CREATE TABLE statement

CREATE TABLE [ table name]  ( [ column definitions]  ) [ table

 parameters] .

CREATE TABLE OFFICES

(OFFICE INTEGER NOT NULL,CITY VARCHAR(15) NOT NULL,

REGION VARCHAR(10) NOT NULL,

MGR INTEGER,

TARGET MONEY,

SALES MONEY NOT NULL)

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 6/14

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 7/14

ALTER statements

 Alter - To modify an existing database object. An ALTER statement

in SQL changes the properties of an object inside of a relational

database management system (RDBMS).

Eg:

 ALTER object type object name parameters 

 ALTER TABLE CUSTOMERS

 ADD CONTACT_NAME VARCHAR(30)

 ALTER TABLE SALESREPSDROP HIRE_DATE

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 8/14

Data Manipulation Language (DML)

DML is abbreviation of Data Manipulation Language. It is used to retrieve,

store, modify, delete, insert and update data in database.

Examples: SELECT, UPDATE, INSERT statements

Used for the following :

retrieval of information from the database

insertion of new information into the database

deletion of information in the database

modif ication of information in the database

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 9/14

Eg:

SELECT * from Student_info

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 10/14

EG :

INSERT INTO ORDERS

(AMOUNT, MFR, PRODUCT, QTY, ORDER _DATE, 

ORDER _NUM, CUST, REP)

VALUES (2340.00, 'ACI', '41004', 20, CURRENT _DATE, 

113069, 2126, 111)

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 11/14

EG :

UPDATE CUSTOMERS

SET  CUST _ID = 109

WHERE COMPAN Y = 'Acme Mfg.'

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 12/14

EG :

DELETE FROM ORDERS

WHERE CUST = 2126

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 13/14

DCL

DCL is abbreviation of Data Control Language.

It is used to create roles, permissions, and referential integrity as well

it is used to control access to database by securing it.

GRANT , REVOKE

TCL

TCL is abbreviation of Transactional Control Language. It is used tomanage different transactions occurring within a database.

COMMIT

ROLLBACK

8/6/2019 Ddl & Dml Final

http://slidepdf.com/reader/full/ddl-dml-final 14/14