Data Definition Language (DDL)

Data Definition Language (DDL)                                                

CREATE:

Syntax:-

CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, .... );

Example:- 

CREATE TABLE book( book_no number, book_name varchar2(20), author_id varchar2(20), price number;

ALTER:-

ADD Columns:

Syntax:-

ALTER TABLE table_name ADD column_name datatype;

Example:-

ALTER TABLE book( ADD QUANTITY number);

Modify Columns:

Syntax:-

ALTER TABLE table_name MODIFY COLUMN column_name datatype;

Example:-

ALTER TABLE book MODIFY COLUMN author_id number;

Rename using alter statement:-

Syntax:-

ALTER TABLE table_name
RENAME TO new_table_name;

Example:-

ALTER TABLE book RENAME to books;

DROP:

Syntax:-

DROP TABLE table_name;

Example:-

DROP TABLE book;

Purpose:-  DROP is used to delete just a table. The DROP statement destroys objects like an existing database, table, index, or view.

TRUNCATE:

Syntax:-

TRUNCATE TABLE table_name;

Example:-

TRUNCATE TABLE book;

Purpose:-     Truncate used to delete all records from the database.

RENAME:-

Syntax:-

RENAME old_table _name To new_table_name;

Example:-

RENAME book to new_books;

 

 

 

Share:

No comments:

Post a Comment

Recent Posts

Service Support

Need our help to Learn or Post New Concepts Contact me