Вы находитесь на странице: 1из 6

-- Create table

create table LOGIN_USER


(
USER_NAME VARCHAR2(10) not null,
USER_PASSWORD VARCHAR2(15),
USER_ACTIVE CHAR(1) default 'Y',
USER_CREATION_DATE DATE default sysdate
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table LOGIN_USER
add constraint PK_USER_NAME primary key (USER_NAME)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);

-- Create table
create table CUSTOMER_PACKAGES
(
PACKAGE_ID VARCHAR2(10) not null,
PACKAGE_DESCRIPTION VARCHAR2(50),
PACKAGE_BUYING NUMBER,
PACKAGE_SELL NUMBER,
PACKAGE_TAX_AMT NUMBER
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table CUSTOMER_PACKAGES
add constraint PK_PACKAGE_ID primary key (PACKAGE_ID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);

-- Create table
create table CUSTOMER_SETUP
(
CUSTOMER_ID NUMBER not null,
CUSTOMER_NAME VARCHAR2(100),
CUSTOMER_ADDRESS VARCHAR2(100),
CONTACT_NO VARCHAR2(15),
CNIC VARCHAR2(15),
CUSTOMER_CREATED_DATE DATE default sysdate,
CUSTOMER_UNDER_PROV VARCHAR2(100),
PACKAGE_USING VARCHAR2(10),
LAST_PKG_USING VARCHAR2(10),
CUSTOMER_ACTIVE_FLAG CHAR(1) default 'Y'
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table CUSTOMER_SETUP
add constraint PK_CUSTOMER_ID primary key (CUSTOMER_ID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
alter table CUSTOMER_SETUP
add constraint FK_LAST_PACKAGE_USED foreign key (LAST_PKG_USING)
references CUSTOMER_PACKAGES (PACKAGE_ID);
alter table CUSTOMER_SETUP
add constraint FK_PACKAGE_USING foreign key (PACKAGE_USING)
references CUSTOMER_PACKAGES (PACKAGE_ID);

-- Create table
create table CUSTOMER_INVOICE_GEN
(
INVOICE_NO NUMBER,
CUSTOMER_ID NUMBER not null,
PACKAGE_ID VARCHAR2(10),
INVOICE_MONTH DATE not null,
INVOICE_MONTH_DESC VARCHAR2(10),
PACKAGE_AMOUNT NUMBER,
PREVIOUS_BALANCE NUMBER,
TAXABLE_AMOUNT NUMBER,
TOTAL_AMOUNT NUMBER,
INVOICE_CREATION_DATE DATE default sysdate,
INVOICE_CREATED_BY VARCHAR2(10),
PACKAGE_EXPIRE_DATE DATE
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table CUSTOMER_INVOICE_GEN
add constraint PK_CUST_ID_MONTH primary key (CUSTOMER_ID, INVOICE_MONTH)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
alter table CUSTOMER_INVOICE_GEN
add constraint UN_INV_NO unique (INVOICE_NO)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
alter table CUSTOMER_INVOICE_GEN
add constraint FK_CUSTOMER_ID foreign key (CUSTOMER_ID)
references CUSTOMER_SETUP (CUSTOMER_ID);
alter table CUSTOMER_INVOICE_GEN
add constraint FK_PKG_ID foreign key (PACKAGE_ID)
references CUSTOMER_PACKAGES (PACKAGE_ID);

-- Create table
create table CUSTOMER_PAYMENTS
(
SEQ_NO NUMBER not null,
INVOICE_NO NUMBER,
CUSTOMER_ID NUMBER,
PACKAGE_ID VARCHAR2(10),
INVOICE_MONTH DATE,
PAID_DATE DATE,
TOTAL_AMOUNT_PAID NUMBER,
PREVIOUS_BALANCE NUMBER,
PAID_FLAG CHAR(1),
REMARKS VARCHAR2(50)
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table CUSTOMER_PAYMENTS
add constraint PK_SEQ_NO primary key (SEQ_NO)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
alter table CUSTOMER_PAYMENTS
add constraint FK_CUST_ID_MON foreign key (CUSTOMER_ID, INVOICE_MONTH)
references CUSTOMER_INVOICE_GEN (CUSTOMER_ID, INVOICE_MONTH);
alter table CUSTOMER_PAYMENTS
add constraint FK_PACKAGE_ID foreign key (PACKAGE_ID)
references CUSTOMER_PACKAGES (PACKAGE_ID);

-- Create table
create table SYSTEM_DEFAULT_PARAM
(
DEFAULT_CODE VARCHAR2(20) not null,
CODE_VALUE VARCHAR2(100)
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table SYSTEM_DEFAULT_PARAM
add constraint PK_DEFAULT_CODE primary key (DEFAULT_CODE)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);

create table CUSTOMER_INVOICE_GEN


(
INVOICE_NO NUMBER,
CUSTOMER_ID NUMBER not null,
PACKAGE_ID VARCHAR2(10),
INVOICE_MONTH DATE not null,
INVOICE_MONTH_DESC VARCHAR2(10),
PACKAGE_AMOUNT NUMBER,
PREVIOUS_BALANCE NUMBER,
TAXABLE_AMOUNT NUMBER,
TOTAL_AMOUNT NUMBER,
PKG_START_DATE DATE default sysdate,
INVOICE_CREATED_BY VARCHAR2(10),
PACKAGE_EXPIRE_DATE DATE
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table CUSTOMER_INVOICE_GEN
add constraint PK_CUST_ID_MONTH primary key (CUSTOMER_ID, INVOICE_MONTH)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
alter table CUSTOMER_INVOICE_GEN
add constraint UN_INV_NO unique (INVOICE_NO)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
alter table CUSTOMER_INVOICE_GEN
add constraint FK_CUSTOMER_ID foreign key (CUSTOMER_ID)
references CUSTOMER_SETUP (CUSTOMER_ID);
alter table CUSTOMER_INVOICE_GEN
add constraint FK_PKG_ID foreign key (PACKAGE_ID)
references CUSTOMER_PACKAGES (PACKAGE_ID);

Вам также может понравиться