SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
DROP TABLE IF EXISTS clients; CREATE TABLE clients ( id number(10), name varchar2(1000), place_of_birth varchar2(1000), date_of_birth date, address varchar2(1000), passport varchar2(100), CONSTRAINT clients_pk primary key (id) ); DROP TABLE IF EXISTS products; CREATE TABLE products ( id number(10), product_type_id number(10), name varchar2(100), client_ref number(10), open_date date, close_date date, CONSTRAINT products_pk primary key (id) ); DROP TABLE IF EXISTS product_type; CREATE TABLE product_type ( id number(10), name varchar2(100) begin_date date, end_date date, tarif_ref number(10), CONSTRAINT product_type_pk primary key (id) ); DROP TABLE IF EXISTS accounts; CREATE TABLE accounts ( id number(10), name varchar2(100), saldo number(10,2), client_ref number(10), open_date date, close_date date, product_ref number(10), acc_num varchar2(25), CONSTRAINT accounts_pk primary key (id) ); DROP TABLE IF EXISTS records; CREATE TABLE records ( id number(10), dt number(1), sum number(10,2), acc_ref number(10), oper_date date, CONSTRAINT records_pk primary key (id) ); DROP TABLE IF EXISTS tarifs; CREATE TABLE tarifs ( id number(10), name varchar2(100), cost number (10,2), CONSTRAINT tarifs_pk primary key (id) ); ALTER TABLE products ADD CONSTRAINT prod_cl_fk FOREIGN KEY (client_ref) REFERENCES clients(id), ADD CONSTRAINT prod_prodtype_fk FOREIGN KEY (product_type_id) REFERENCES product_type(id); ALTER TABLE product_type ADD CONSTRAINT product_type_fk FOREIGN KEY (tarif_ref) REFERENCES tarifs(id); ALTER TABLE records CONSTRAINT rec_acc_fk FOREIGN KEY (acc_ref) REFERENCES accounts(id); ALTER TABLE accounts ADD CONSTRAINT acc_cl_fk FOREIGN KEY (client_ref) REFERENCES clients(id), ADD CONSTRAINT acc_prod_fk FOREIGN KEY (product_ref) REFERENCES products(id);

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear