

-- if necessary  
DROP TABLE vendors;

-- use a squence as default value for the column
CREATE TABLE vendors
(
  vendor_id    NUMBER        DEFAULT vendor_id_seq.NEXTVAL PRIMARY KEY,
  vendor_name  VARCHAR2(50)  NOT NULL      UNIQUE
);

DROP TABLE vendors;

-- simple GENERATED clause
CREATE TABLE vendors
(
  vendor_id    NUMBER        GENERATED AS IDENTITY PRIMARY KEY,
  vendor_name  VARCHAR2(50)  NOT NULL      UNIQUE
);

DROP TABLE vendors;

--more complex GENERATED clause
CREATE TABLE vendors
(
  vendor_id    NUMBER        GENERATED BY DEFAULT 
                             AS IDENTITY ( START WITH 124) PRIMARY KEY,
  vendor_name  VARCHAR2(50)  NOT NULL      UNIQUE
);

-- Test DEFAULT keyword
INSERT INTO vendors VALUES (DEFAULT, 'default test');

-- Test column list
INSERT INTO vendors (vendor_name) VALUES ('column list test');

-- View results
SELECT * FROM vendors;