lab 1
lab 1
Alter: This is a DDL command used to alter or update the definition of an entity. using this
command has multiple purposes. they are as follows:
Syntax:
alter table <table_name> add <attribute_name> datatype;
alter table <table_name> drop column <attibute_name>;
alter table <table_name> rename column <attribute_name_old> to <attribute_name_new>;
alter table <table_name> modify <column_name> <datatype>; ------after version 10g of software.
alter table <old_table_name> rename to <new_table_name>;
Rename: As suggested above this can be used to rename entity. but, it can also rename views and DBs.
Syntax:
rename <old_table_name> to <new_table_name>;
Drop: This command is used to remove entity or views from the DB.
Syntax:
drop table <table_name>;
Insert: This command is used to insert the data onto the entity. This has the following syntax.
Syntax:
insert into <table_name> (attribute_1,attribute_2,.....,attribuite_n) values (value11,value12,......value_1n),
(value21,value22,......value_2n);
SQL> create table students (sid number primary key, sname varchar2(20) not null, rank number not null);
Table created.
Table altered.
Table altered.
Table altered.
Table altered.
SQL> alter table students rename to sdata;
Table altered.
2 rows created.
Table dropped.
SQL>
Result: All the queries related to the task 1 are executed as per the specifications.