Professional Documents
Culture Documents
SQL DAY 1
SQL DAY 1
SQL DAY 1
Syntax:ALTER TABLE table_name
ADD column_name datatype;
SYNTAX:ALTER TABLE table_name
DROP COLUMN column_name;
we can change or modify once tables columns data type and their size by using ALTER
command as follows
SYNTAX:
ALTER TABLE table_name
MODIFY COLUMN column_name datatype;
ALTER TABLE DEPT MODIFY COLUMN DNAME VARCHAR2(24)
ALTER TABLE STUDENT1
ADD CHECK (Age>=18);
DEPT Table Data:
20 Research Dallas
30 Sales Chicago
40 Operations Boston
insert into emp values (101,'SMITH','CLERK',102,'93/6/13',800,0.00,20);
insert into emp values (102,'ALLEN','SALESMAN',108,'98/8/15',1600,300,30);
insert into emp values (103,'WARD','SALESMAN',108,'96/3/26',1250,500,30);
insert into emp values (104,'JONES','MANAGER',102,'95/10/31',2975,null,20);
insert into emp values (105,'BLAKE','MANAGER',103,'92/6/11',2850,null,30);
insert into emp values (106,'CLARK','MANAGER',102,'93/5/14',2450,null,10);
insert into emp values (107,'SCOTT','ANALYST',108,'96/3/5',3000,null,20);
insert into emp values (108,'KING','PRESIDENT',null,'90/6/9',5000,0,10);
NO NAME AGE
101 RAMA 40
NO NAME AGE
101 RAMA 60
Example:
NO NAME AGE
101 RAMA 60
102 RAVANA 60
NO NAME AGE
101 RAMA 60
We can DELETE the ALL RECORDS (rows data) from a table using DELETE FROM COMMAND,
DELETE FROM table_name;
The TRUNCATE TABLE statement is used to delete the data inside a table, but not the
table itself.
Syntax:TRUNCATE TABLE table_name;