Skip to content

Commit

Permalink
修复SQL异常问题
Browse files Browse the repository at this point in the history
修复SQL异常问题,新建创建、删除sql文件
  • Loading branch information
zhanglei-workspace committed May 13, 2016
1 parent 747a4cf commit 4b8f1f2
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 64 deletions.
1 change: 0 additions & 1 deletion 1#Java菜鸟项目/lyons.eaby/WebRoot/sql/classify.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ create table classify
gid number(11) primary key,
gname varchar2(200) not null
);

-- Ϊclassify������gid����Ψһ ����
create sequence classify_seq
start with 1
Expand Down
17 changes: 2 additions & 15 deletions 1#Java菜鸟项目/lyons.eaby/WebRoot/sql/commodity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,11 @@ create sequence commodity_seq
cache 10

--����������
create trigger commodity_tigger
create trigger commodity_trigger
before insert on commodity
for each row
begin
select commodity_seq.nextval into :new.commodity_number from dual;
end;



INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('��������Ь', '��ɽ', 180, 500, '001.jpg',5);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('��̤�˶�Ь', '����', 120, 800, '002.jpg',5);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('�Ϳ��˶�Ь', '����', 500, 1000, '003.jpg',5);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('���ϴ�˹TѪ��', '�Ϻ�', 388,600,'004.jpg',6);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('�����Ļ���', '����', 180, 900, '005.jpg',6);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('��3', '����', 1999, 3000, '006.jpg',7);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('��2S', '����', 1299, 1000, '007.jpg',7);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('thinkpad�ʼDZ�', '����', 6999, 500, '008.jpg',8);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('dell�ʼDZ�', '����', 3900, 500, '009.jpg',8);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('ipad5', '����', 5900, 500, '010.jpg',8);



99 changes: 99 additions & 0 deletions 1#Java菜鸟项目/lyons.eaby/WebRoot/sql/createTable.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
--��Ʒ�����01--
create table classify
(
gid number(11) primary key,
gname varchar2(200) not null
);

--Ϊclassify������gid����Ψһ ����--
create sequence classify_seq
start with 1
increment by 1
minvalue 1
maxvalue 10000
nocycle
cache 10;

--����������--
create trigger classify_trigger
before insert on classify
for each row
begin
select classify_seq.nextval into :new.gid from dual;
end;



--commodity�� ������Ʒ��Ϣ02--

create table commodity
(
commodity_number varchar2(255) primary key,
commodity_name varchar(255) not null,
commodity_made varchar2(255),
commodity_price NUMBER(18,2) not null,
commodity_balance NUMBER(7) not null,
commodity_pic varchar2(255)not null,
commodity_id number(11) references classify(gid) not null
);

--Ϊcommodity������gid����Ψһ ����--
create sequence commodity_seq
start with 1
increment by 1
minvalue 1
maxvalue 100000
nocycle
cache 10;

--����������--
create trigger commodity_trigger
before insert on commodity
for each row
begin
select commodity_seq.nextval into :new.commodity_number from dual;
end;


--orderForm������03 --
create table orderForm
(
id number(10) primary key,
commodity_name varchar2(255) not null,
commodity_price NUMBER(18,2) not null,
orderDate DATE DEFAULT SYSDATE NOT NULL,
sum number(18,2)
);

--��������--
CREATE SEQUENCE orderForm_seq
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 100000
NOCYCLE
CACHE 10;

--������--
CREATE TRIGGER orderForm_trigger
BEFORE INSERT ON orderForm
FOR EACH ROW
BEGIN
SELECT orderForm_seq.nextval into :new.id FROM dual;
END;

--�û���vip
create table vip
(
username varchar2(255) primary key,
userpass varchar2(255) not null,
phone varchar2(255),
address varchar2(255),
realname varchar2(255)
);

commit;

INSERT INTO vip(username,userpass,phone,address,realname) VALUES('lyons','123456','15853123329','����','���')

select * from commodity
9 changes: 5 additions & 4 deletions 1#Java菜鸟项目/lyons.eaby/WebRoot/sql/orderForm.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
create table orderForm
(
id number(10) primary key,
username varchar2(255),
mess varchar2(255),
commodity_name varchar2(255) not null,
commodity_price NUMBER(18,2) not null,
orderDate DATE DEFAULT SYSDATE NOT NULL,
sum number(18,2)
);

Expand All @@ -16,7 +17,7 @@ CREATE SEQUENCE orderForm_seq
MINVALUE 1
MAXVALUE 100000
NOCYCLE
CACHE 10
CACHE 10;

--������

Expand All @@ -25,5 +26,5 @@ CREATE TRIGGER orderForm_trigger
FOR EACH ROW
BEGIN
SELECT orderForm_seq.nextval into :new.id FROM dual;
END
END;
commit;
44 changes: 0 additions & 44 deletions 1#Java菜鸟项目/lyons.eaby/WebRoot/sql/test---items.sql

This file was deleted.

46 changes: 46 additions & 0 deletions 1#Java菜鸟项目/lyons.eaby/WebRoot/sql/testTable.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@


-- insert into classify
insert into classify(gname) values('鞋子');
insert into classify(gname) values('衬衫');
insert into classify(gname) values('手机');
insert into classify(gname) values('电子产品');
commit;

drop trigger classify_tigger
-- insert into commodity

INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('沃特篮球鞋', '佛山', 180, 500, '001.jpg',1);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('安踏运动鞋', '福州', 120, 800, '002.jpg',1);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('耐克运动鞋', '广州', 500, 1000, '003.jpg',1);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('阿迪达斯T血衫', '上海', 388,600,'004.jpg',2);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('李宁文化衫', '广州', 180, 900, '005.jpg',2);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('小米3', '北京', 1999, 3000, '006.jpg',3);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('小米2S', '北京', 1299, 1000, '007.jpg',3);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('thinkpad笔记本', '北京', 6999, 500, '008.jpg',4);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('dell笔记本', '北京', 3900, 500, '009.jpg',4);
INSERT INTO commodity(commodity_name,commodity_made,commodity_price,commodity_balance,commodity_pic,commodity_id) VALUES ('ipad5', '北京', 5900, 500, '010.jpg',4);

--Drop all table 注意删除顺序--
drop trigger commodity_trigger;
commit;
drop sequence commodity_seq;
commit;
drop table commodity;
commit;

drop trigger classify_trigger;
commit;
drop sequence classify_seq;
commit;
drop table classify;
commit;

drop trigger orderForm_trigger;
commit;
drop sequence orderForm_seq;
commit;
drop table orderForm ;
commit;


0 comments on commit 4b8f1f2

Please sign in to comment.