PL/SQL Create table

Create sequence

CREATE SEQUENCE course_seq 
MINVALUE 1 
MAXVALUE 999999999999999999999999999 
START WITH 1 
INCREMENT BY 1 
CACHE 20;

Create table

CREATE TABLE course(
course_id NUMBER NOT NULL,
name VARCHAR2(250) NOT NULL,
description VARCHAR2(4000),
duration VARCHAR2(25),
price NUMBER,
CONSTRAINT pk_course_id PRIMARY KEY(course_id)
);

Create trigger

CREATE OR REPLACE TRIGGER course_t1
  BEFORE INSERT ON course
  FOR EACH ROW
DECLARE
BEGIN
  IF :new.course_id IS NULL THEN
    SELECT course_seq.nextval INTO :new.course_id FROM dual;
  END IF;
END;

Insert into table

SET DEFINE OFF;
Insert into COURSE (NAME,DESCRIPTION,DURATION,PRICE) values ('SQL 1','SQL course for beginners','1 week',10);
Insert into COURSE (NAME,DESCRIPTION,DURATION,PRICE) values ('SQL 2','SQL course for advanced','2 weeks',50);
Insert into COURSE (NAME,DESCRIPTION,DURATION,PRICE) values ('HTML5','Learn HTML 5','1 week',10);
Insert into COURSE (NAME,DESCRIPTION,DURATION,PRICE) values ('PHP','PHP course','4 weeks',75);
Insert into COURSE (NAME,DESCRIPTION,DURATION,PRICE) values ('CSS','Learn CSS','2 weeks',20);
COMMIT;

Create table backup

CREATE TABLE course_backup AS SELECT * FROM course;
COURSE_ID NAME DESCRIPTION DURATION PRICE
1 SQL 1 SQL course for beginners 1 week 10
2 SQL 2 SQL course for advanced 2 week 50
3 HTML5 Learn HTML 5 1 week 10
4 PHP PHP course 4 week 75
5 CSS Learn CSS 2 week 20