Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first commit #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/0#Java基础项目.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions shopping-management-system/files/sql文件/GOODS.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--�������ݿ�����飬���� GOODS ����

CREATE TABLE GOODS
(
gid NUMBER(10) primary key,
gname VARCHAR2(20) NOT NULL UNIQUE,
gprice NUMBER(18,2) NOT NULL,
gnum NUMBER(11) NOT NULL
);

--����gid�����Զ����ɡ�����������ʵ�֣�

--1.ΪGOODS������Ψһ ����

CREATE SEQUENCE goods_seq --�����������ȡ
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 100000 --�����ֵ�����������
NOCYCLE --����maxvalues�󣬲���ѭ����
CACHE 10 --ÿ����ǰ����10�������Ч�ʣ������������


--2.Ϊ������ ������ �������Զ�������ȡֵ��GOODS����gid�Զ���ֵ

CREATE TRIGGER goods_trigger
BEFORE INSERT ON goods
FOR EACH ROW --�м��������������ÿһ�����ݶ��ᴥ��
BEGIN --�������л�ȡ�µ���Ų����� ���� ��gid �ֶ�
SELECT goods_seq.nextval INTO :new.gid FROM dual;
END;


--truncate �ܹ�������ݣ�Ȼ��������Ĩ�����еļ��䡣
35 changes: 35 additions & 0 deletions shopping-management-system/files/sql文件/GSALES.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--�������ݿ�˵���飬������Ʒ���۱� GSALES
---���ڴ˱��Ľ������Բο�������oracle�����е����£�֪ʶ���е��

--oracle ��֧�ּ������£����ˣ�
--ע�⣬��������
CREATE TABLE gsales
(
gsid NUMBER(10) PRIMARY KEY,
--����������������,
gid NUMBER(10) REFERENCES goods(gid) NOT NULL,
sid NUMBER(10) REFERENCES salesman(sid) NOT NULL,
sdate DATE DEFAULT SYSDATE NOT NULL, --�������ݸĶ�ʱ�Զ���ȡϵͳʱ�䲢ͬ�������ݿ�
snum NUMBER(11) NOT NULL
);

--��������

CREATE SEQUENCE gsales_seq
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 100000
NOCYCLE
CACHE 10

--������

CREATE TRIGGER gsales_trigger
BEFORE INSERT ON gsales
FOR EACH ROW
BEGIN
SELECT gsales_seq.nextval into :new.gsid FROM dual;
END
commit;

30 changes: 30 additions & 0 deletions shopping-management-system/files/sql文件/SALESMAN.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--�������ݿ�˵���齨�� ӪҵԱ�� //SID �Զ�����

CREATE TABLE salesman
(
sid NUMBER(10) PRIMARY KEY,
sname VARCHAR2(10) NOT NULL UNIQUE,
spassword VARCHAR(20) NOT NULL

)

--��������

CREATE SEQUENCE salesman_seq
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 100000
NOCYCLE
CACHE 10

--������

CREATE TRIGGER salesman_trigger
BEFORE INSERT ON salesman
FOR EACH ROW
BEGIN
SELECT salesman_seq.nextval INTO :new.sid FROM dual;
END;

--�û�Υ��ΨһԼ����δ�����Ϣʱ����ռ���Զ����ɵ����кţ��Ҿ���������ܴ��ڰ�ȫ������
25 changes: 25 additions & 0 deletions shopping-management-system/files/sql文件/java_sql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
select * from gsales
select * from goods
select * from salesman

--չʾ������Ʒ�б����ö��������sql���ͣ�
------------------------------------------------------
select gname,gprice,gnum, allSum --�����±�����Ŀ

from goods, (select gid as salesid,sum(snum) as allSum --�����������������һ�ű�
from gsales --��gid��ͬ��������
where trunc(sdate) = trunc(sysdate) --ʱ���ϵͳ��ȡ�������������sdateʱ����ͬ
group by gid)
where gid = salesid --goods���������������ű���ȡgid��salessid�Ľ���
------------------------------------------------------

--֪ʶ��磺
select trunc(sysdate) from dual;
select trunc(sysdate) + 1 from dual;
select sysdate from dual; --��ϵͳ��ȡʱ��

select sid,to_char(sdate,'yyyy/mm/dd') from gsales --ת��ʱ�������ʽ��ע�⣺�ֶεĸ�ʽ���ܱ�ת��




Binary file not shown.
Binary file not shown.
Loading