Table creation:
The user must be displayed with the permission to create a trigger.
1. log on to sqlplus with sys/1234
2. In the command window, enter grant create any trigger to sprita1;
3. The message "Grant succeeded" indicates that the authorization is successful.
Create a table with an auto-increment primary key:
Create Table student
(
ID number not null primary key,
Name varchar2 (20) not null,
Gender varchar2 (20) not null,
Startdate date not null
);
// Comment
Comment on table student is 'student info table ';
Comment on column student. ID is 'id ';
Comment on column student. Name is 'name ';
Comment on column student. Gender is 'gender ';
Comment on column student. startdate is 'admission date ';
// Sequence
Create sequence st_sqc increment by 1;
// Trigger
Create or replace trigger std_tg_insert before insert on student for each row
Begin
Select st_sqc.nextval into: New. ID from SYS. Dual;
End;