create table in oracle sql example
Example 1: create table oracle
CREATE TABLE ot.persons(
person_id NUMBER GENERATED BY DEFAULT AS IDENTITY,
first_name VARCHAR2(50) NOT NULL,
last_name VARCHAR2(50) NOT NULL,
PRIMARY KEY(person_id)
);
Example 2: oracle sql create table
DROP TABLE vehicles;
DROP TABLE owners;
CREATE TABLE owners (
owner_id NUMBER,
first_name VARCHAR2(50 CHAR) NOT NULL,
CONSTRAINT owners_pk PRIMARY KEY(owner_id)
);
CREATE TABLE vehicles (
vehicle_id NUMBER,
vehicle_name VARCHAR2(50 CHAR) NOT NULL,
CONSTRAINT vehicle_owner_fk FOREIGN KEY(vehicle_id) REFERENCES owners(owner_id) ON DELETE SET NULL
);
INSERT INTO owners VALUES(1, 'Abbi');
INSERT INTO owners VALUES(2, 'Beatrix');
INSERT INTO owners VALUES(3, 'Caila');
INSERT INTO owners VALUES(4, 'Dea');
INSERT INTO owners VALUES(5, 'Elise');
INSERT INTO vehicles VALUES(1, 'car');
INSERT INTO vehicles VALUES(2, 'motorcycle');
INSERT INTO vehicles VALUES(3, 'airplane1');
INSERT INTO vehicles VALUES(4, 'airplane1');
INSERT INTO vehicles VALUES(4, 'steamer');
INSERT INTO vehicles VALUES(4, 'submarine');
COMMIT;
DELETE FROM projects WHERE vehicle_id = 4 AND vehicle_name = 'submarine';