SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- Создание таблицы TARIFS CREATE TABLE TARIFS ( ID NUMBER PRIMARY KEY, NAME VARCHAR2(255) NOT NULL, COST NUMBER(10, 2) NOT NULL ); -- Создание таблицы CLIENTS CREATE TABLE CLIENTS ( ID NUMBER PRIMARY KEY, NAME VARCHAR2(255) NOT NULL, PLACE_OF_BIRTH VARCHAR2(255) NOT NULL, DATE_OF_BIRTH DATE NOT NULL, ADDRESS VARCHAR2(255), PASSPORT VARCHAR2(255) UNIQUE NOT NULL ); -- Создание таблицы PRODUCT_TYPE CREATE TABLE PRODUCT_TYPE ( ID NUMBER PRIMARY KEY, NAME VARCHAR2(255) NOT NULL, BEGIN_DATE DATE NOT NULL, END_DATE DATE, TARIF_REF NUMBER, FOREIGN KEY (TARIF_REF) REFERENCES TARIFS(ID) ); -- Создание таблицы PRODUCTS CREATE TABLE PRODUCTS ( ID NUMBER PRIMARY KEY, PRODUCT_TYPE_ID NUMBER NOT NULL, NAME VARCHAR2(255) NOT NULL, CLIENT_REF NUMBER NOT NULL, OPEN_DATE DATE NOT NULL, CLOSE_DATE DATE, CONSTRAINT FK_PRODUCTS_PRODUCT_TYPE FOREIGN KEY (PRODUCT_TYPE_ID) REFERENCES PRODUCT_TYPE(ID), CONSTRAINT FK_PRODUCTS_CLIENTS FOREIGN KEY (CLIENT_REF) REFERENCES CLIENTS(ID) ); -- Создание таблицы ACCOUNTS CREATE TABLE ACCOUNTS ( ID NUMBER PRIMARY KEY, NAME VARCHAR2(255) NOT NULL, SALDO NUMBER(10, 2) DEFAULT 0.00, CLIENT_REF NUMBER NOT NULL, OPEN_DATE DATE NOT NULL, CLOSE_DATE DATE, PRODUCT_REF NUMBER, ACC_NUM VARCHAR2(50) UNIQUE NOT NULL, CONSTRAINT FK_ACCOUNTS_CLIENTS FOREIGN KEY (CLIENT_REF) REFERENCES CLIENTS(ID), CONSTRAINT FK_ACCOUNTS_PRODUCTS FOREIGN KEY (PRODUCT_REF) REFERENCES PRODUCTS(ID) ); -- Создание таблицы RECORDS CREATE TABLE RECORDS ( ID NUMBER PRIMARY KEY, DT NUMBER(1) NOT NULL CHECK (DT IN (0, 1)), ACC_REF NUMBER NOT NULL, OPER_DATE DATE NOT NULL, SUM NUMBER(10, 2) NOT NULL, CONSTRAINT FK_RECORDS_ACCOUNTS FOREIGN KEY (ACC_REF) REFERENCES ACCOUNTS(ID) );

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear