1. Learning of DDL language
1.create keyword, used to create table structure
/* format is as follows:
create table tname(
colName dataType,
colName dataType,
………………
colName dataType
);
*/
2: alter, used to Modify the table structure
1) Add the fields of the table
--Format: alter table tname add (colName dataType);
--Exercise: add a field to the table temp_1, the tag type is number, the length is 2
alter table temp_1 add (tage number(2) );
2) Delete the fields of the table
-- Format: alter table tname drop column
colName -- Exercise: delete the tage in the temp_1 table
alter table temp_1 drop column tage;
3) Modify the name of the field
-- Format: alter table tname rename column oldName to newName
-- Exercise: Modify the tname of table temp_1 to name
alter table temp_1 rename column tname to name;
4) Modify the data type of the field
-- Format: alter table tname modify colName dataType
-- Exercise: Modify the name in the temp_1 table to varchar2 (30);
alter table temp_1 modify name varchar2(30);
5) Modify table name
-- format: rename oldTname to newTname
-- exercise: modify temp_1 to temp_2;
rename temp_1 to temp_2;
6) delete table structure
-- format: drop table tname;
-- Exercise: delete temp_2
drop table temp_2;
7) View the table structure
-- Format: desc tname;
-- Exercise: Create temp_1, view the table structure
desc temp_1;