CREATE TABLESPACE DATA_RESTRANT DATAFILE 'D:\app\myj\oradata\PS\RESTRANT\DataRestrant.DBF' SIZE 100M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED DEFAULT STORAGE (INITIAL 10K NEXT 10M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0);
create user rootmyj identified by psmyj311
default tablespace DATA_RESTRANT
temporary tablespace temp
quota unlimited on DATA_RESTRANT
-- quota unlimited on temp;
grant dba to rootmyj;
--下边不执行
revoke dba from rootmyj;
grant unlimited tablespace to rootmyj;
grant delete any table to rootmyj;
grant insert any table to rootmyj;
grant select any table to rootmyj;
grant update any table to rootmyj;
grant backup any table to rootmyj;
grant create session to rootmyj;
grant connect to rootmyj;
grant restricted session to rootmyj;
grant execute any procedure to rootmyj;
grant create any trigger to rootmyj;
grant drop any trigger to rootmyj;
-- Create table
create table USERS
(
id INTEGER not null,
loginname VARCHAR2(20) not null,
loginpwd VARCHAR2(20) not null,
truename VARCHAR2(20) not null,
email VARCHAR2(20),
phone VARCHAR2(20) not null,
address VARCHAR2(50) not null
)
tablespace DATA_RESTRANT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table USERS
add constraint PK_USERS primary key (ID)
using index
tablespace DATA_RESTRANT
pctfree 10
initrans 2
maxtrans 255;
-- Create table
create table ADMIN
(
id INTEGER not null,
loginname VARCHAR2(20) not null,
loginpwd VARCHAR2(20) not null
)
tablespace DATA_RESTRANT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table ADMIN
add constraint PK_ADMIN primary key (ID)
using index
tablespace DATA_RESTRANT
pctfree 10
initrans 2
maxtrans 255;
-- Create table
create table MEALSERIES
(
seriesid INTEGER not null,
seriesname VARCHAR2(10)
)
tablespace DATA_RESTRANT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table MEALSERIES
add constraint PK_MEALSERIES primary key (SERIESID)
using index
tablespace DATA_RESTRANT
pctfree 10
initrans 2
maxtrans 255;
-- Create table
create table MEAL
(
mealid INTEGER not null,
mealseriesid INTEGER not null,
mealname VARCHAR2(20) not null,
mealsummarize VARCHAR2(250) not null,
mealdescription VARCHAR2(250) not null,
mealprice NUMBER(8,2) not null,
mealimage VARCHAR2(20) not null
)
tablespace DATA_RESTRANT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table MEAL
add constraint PK_MEAL primary key (MEALID)
using index
tablespace DATA_RESTRANT
pctfree 10
initrans 2
maxtrans 255;
alter table MEAL
add constraint FK_MEAL foreign key (MEALSERIESID)
references MEALSERIES (SERIESID);
-- Create table
create table ORDERS
(
oid INTEGER not null,
userid INTEGER not null,
ordertime DATE not null,
orderstate VARCHAR2(20) not null,
orderprice NUMBER(8,2) not null
)
tablespace DATA_RESTRANT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table ORDERS
add constraint PK_ORDERS primary key (OID)
using index
tablespace DATA_RESTRANT
pctfree 10
initrans 2
maxtrans 255;
alter table ORDERS
add constraint FK_ORDERS foreign key (USERID)
references USERS (ID);
-- Create table
create table ORDERDTS
(
odid INTEGER not null,
oid INTEGER not null,
mealid INTEGER not null,
mealprice NUMBER(8,2) not null,
mealcount INTEGER not null
)
tablespace DATA_RESTRANT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table ORDERDTS
add constraint PK_ORDERDTS primary key (ODID)
using index
tablespace DATA_RESTRANT
pctfree 10
initrans 2
maxtrans 255;
alter table ORDERDTS
add constraint FK_ORDERDTS foreign key (OID)
references ORDERS (OID);
alter table ORDERDTS
add constraint FK_ORDERDTS1 foreign key (MEALID)
references MEAL (MEALID);
-- Create sequence
create sequence SEQ_USERS
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
cache 20;
-- Create sequence
create sequence SEQ_ADMIN
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
cache 20;
-- Create sequence
create sequence SEQ_MEALSERIES
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
cache 20;
-- Create sequence
create sequence SEQ_MEAL
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
cache 20;
-- Create sequence
create sequence SEQ_ORDERS
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
cache 20;
-- Create sequence
create sequence SEQ_ORDERDTS
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
cache 20;
insert into MEALSERIES t(t.seriesid,t.seriesname)values(seq_mealseries.nextval,'川味热菜');
insert into MEALSERIES t(t.seriesid,t.seriesname)values(seq_mealseries.nextval,'川味凉菜');
insert into MEALSERIES t(t.seriesid,t.seriesname)values(seq_mealseries.nextval,'营养汤');