📄 create.sql
字号:
---------------------------------------------------------------------------------------------
-- build data table structure
--------------------------------------------------------------------------------------------
-------drop table product
drop table product;
-------drop table sort----
drop table sort;
------drop table users---
drop table users;
-------create table users----
create table users(
id number,
username varchar2(20) not null unique,
password varchar2(20) not null
);
-----add constraint to table users----
alter table users add constraint primary key (id);
----drop sequence users_seq---
drop sequence users_seq;
----create sequence for table users---
create sequence users_seq increment by 1 start with 10000 nomaxvalue nocycle;
----insert a record into users---
insert into users values (users_seq.nextval, 'admin', 'admin');
-------create table sort----
create table sort(
id number(8),
name varchar2(20) not null
);
------add constraint to table sort----
alter table sort add constraint PK_SORT primary key (id);
-----drop sequence sort_seq-----
drop sequence sort_seq;
----create sequence sort_seq for table sort----
create sequence sort_seq increment by 1 start with 100 nomaxvalue nocycle;
----create table product-------
create table product(
id number(8),
sortid number(8) not null,
name varchar2(50) not null,
price number(7, 2) not null,
saleprice number(7, 2) not null,
descript varchar2(500) not null,
contents varchar2(2000),
saledate date not null,
salecount number,
image varchar2(50)
);
----add constraint to table product---
alter table product add constraint PK_PRODUCT primary key (id);
alter table product add constraint FK_PRODUCT_SORT foreign key (sortid) references sort (id) on delete cascade;
----drop sequence product_seq--
drop sequence product_seq;
----create sequence for table product-----
create sequence product_seq increment by 1 start with 1000 nomaxvalue nocycle;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -