1. Create a table, delete a table, copy a table
CREATE TABLE stuinfo-- creating learner information Tables
(
Stuno Char (6) NOT NULL
Stuname varchar (2) not nul,
Stuage number (3,0) NOT NULL
)
Create a new table copy the Learner Information table is:CREATE TABLE StuInfo2 as SELECT * from Stuinfo;
Delete Table: 1, drop table Table 2, truncate tables;
2, the table structure of the query: DESC table name;
3, change the table name: ALTER TABLE old table name rename to new table name;
Add columns: ALTER TABLE table Add (column name type, column name type);
Modify columns: ALTER TABLE table modify (column name type, column name type);
Delete a column: ALTER TABLE table drop column name; Delete multiple columns: ALTER TABLE Table drop (column 1, column 2);
4, add a constraint to the table, the EMP table Deptno as a Foreign Key reference dept Table Deptno
ALTER TABLE EMP Add constraint pk_test foreign KEY (deptno) References dept (DEPTNO);
5. Add a PRIMARY KEY constraint to the table
ALTER TABLE EMP ADD constraint Pk_emp_deptno primary key (DEPTNO);
6. Delete the constraint:
ALTER TABLE EMP drop constraint Pk_emp_deptno;
7. Disabling and enabling constraints:
ALTER TABLE Table Dsable| | Enable constraint constraint name;
Oracle data table creation, query, constraints, and other operations