Friday, October 30, 2015

Database - DDL

DDL Commands - Create - Drop - Alter - Rename - Truncate

The Create Table Command

The create table command defines each column of the table uniquely. Each column has minimum of three attributes.
Name
Data type
Size(column width).


CREATE TABLE Student
             (Reg_no varchar2(10),
              Name char(30),
              DOB date,
              Address varchar2(50));



The DROP Command

DROP TABLE Student;

It will destroy the table and all data which will be recorded in it.


The TRUNCATE Command

TRUNCATE TABLE Student;


The RENAME Command

RENAME old_name TO new_name


The ALTER Table Command

By The use of ALTER TABLE Command we can modify our exiting table.

ALTER TABLE Student ADD (Age number(2), Marks number(3));



Dropping a Column from the Table

ALTER TABLE Student DROP COLUMN Age;


Modifying Existing Table

ALTER TABLE Student MODIFY (Name Varchar2(40));

No comments:

Post a Comment