Run the edit D:/a. SQL command to edit the SQL statement in a text file. Run @ D:/a. SQL to run the text file you just edited.
Create is creation, alter is modification, drop is Deletion
SQL plus is used in the following operations. If an error occurs, you can use the drop... command to delete it:
Add primary key:
Based on the primary key of one column: alter table test add constraint pk_test primary key (ename );
The Union primary key based on multiple columns: alter table test add constraint pk_test primary key (ename, birthday );
ID of the auto-increment type:
First create sequence:
Minvalue 1 maxvalue 999999999
Increment by 1
Start with 1
Nocycle noorder nocache;
Then create a trigger:
Create trigger trigger_name
Before insert on table_name
For each row
Begin
Select sequence_name.nextval into: New. ID from dual;
End;
Delete sequence: drop sequence emergency_sche_id;
Delete trigger: Drop trigger emergency_event_id_incret;
Create a foreign key constraint:
Alter table students
Add constraint fk_students_state
Foreign key (state) References state_lookup (State );
Reference page: http://wallimn.iteye.com/blog/703921