0009 notes 05-Table creation and constraints, SQL required notes 05-
1. CREATE a TABLE: Use the create table statement to specify the TABLE name (which cannot be the same as the existing TABLE name), column name, and data type of each column.
CREATE TABLE product( prod_id char(10), vend_id char(10), prod_name char(254), prod_price number(8,2), prod_desc varchar(1000) );
Create table product (prod_id char (10) not null primary key, vend_id char (10) not null, prod_name char (254) not null, prod_price number (8, 2) not null check (prod_price> 0), prod_desc varchar (1000) not null, CONSTRAINT for_vend_id foreign key (vend_id) REFERENCES vendors (vend_id ));
Or:
CREATE TABLE product( prod_id char(10) NOT NULL, vend_id char(10) NOT NULL, prod_name char(254) NOT NULL, prod_price number(8,2) NOT NULL, prod_desc varchar(1000) NOT NULL,PRIMARY KEY(prod_id),CHECK(prod_price>0),CONSTRAINT for_vend_id FOREIGN KEY(vend_id) REFERENCES vendors(vend_id));