CREATE TABLE tablename (
col1 data_type col_constraint,
col2 data_type col_constraint,
...
table_constraint
);
For example:
CREATE TABLE authors (
author_id NUMBER GENERATED BY DEFAULT AS IDENTITY (CACHE 500),
firstname VARCHAR2(50) NOT NULL,
lastname VARCHAR2(50) NOT NULL,
age NUMBER,
PRIMARY KEY (author_id)
);
Identity columns are similar to the AUTO_INCREMENT column in MySQL. Here are the different options that can be used.
GENERATED ALWAYS AS IDENTITY: value is automatically generated, and no other value can be specified.
GENERATED BY DEFAULT AS IDENTITY: value is automatically generated if no column value is specified. NULL value cannot be assigned.
GENERATED BY DEFAULT ON NULL AS IDENTITY: value is automatically generated if a no value, including NULL, is set.
Sequence Generator Attributes
CYCLE: when the max value is reached, it will restart, starting with the min valueCACHE [num]: stores a certain number of values in the cache for fast retrievalSTART WITH [num]: specify the starting value (1 by default)INCREMENT BY [num]: specify the increment value between each identity (1 by default)The full list of attributes can be found here.
Views are basically virtual tables that are composed of subset data, i.e. results from queries, obtained from one or more tables.