SQL Tutorial 1: Table Creation, Table Dropping, Constraint Designation

preview_player
Показать описание
drop table tut_customer cascade constraints;
drop table tut_supplier cascade constraints;
drop table tut_product cascade constraints;
drop table tut_product_order cascade constraints;

create table tut_customer(
customer_id number(3),
first_name varchar2(30),
last_name varchar2(30),
street varchar2(30),
city varchar2(30),
state char(2),
zip number(5),
phone number(10),
constraint tut_customer_pk primary key (customer_id)
);

create table tut_supplier(
supplier_id number(3),
name varchar2(30),
street varchar2(30),
city varchar2(30),
state char(2),
zip number(5),
phone number(10),
constraint tut_supplier_pk primary key (supplier_id)
);

create table tut_product(
product_id number(3),
product_name varchar2(30),
quantity_in_stock number(2),
reorder_point number(2),
price number(5,2),
supplier_id number(3),
constraint tut_product_pk primary key (product_id),
constraint tut_product_fk1 foreign key (supplier_id) references tut_supplier(supplier_id)
);

create table tut_product_order(
order_id number(4),
product_id number(3),
customer_id number(3),
order_date date,
ship_date date,
payment_type varchar2(30),
constraint tut_product_order_pk primary key (order_id, product_id),
constraint tut_product_order_fk1 foreign key (product_id) references tut_product(product_id),
constraint tut_product_order_fk2 foreign key (customer_id) references tut_customer(customer_id),
constraint tut_product_payment_ck check ((payment_type = 'Check') or (payment_type = 'CC'))
);
Рекомендации по теме
Комментарии
Автор

Seemed like a good tutorial, but I had to switch to another video because of the sound.

DuckMc
welcome to shbcf.ru