diff --git a/57dca20a5410af42a3eb24e378a89aa.png b/57dca20a5410af42a3eb24e378a89aa.png new file mode 100644 index 0000000000000000000000000000000000000000..a913a682d7a1f040f5abfb529dfa5078d4cbb65a Binary files /dev/null and b/57dca20a5410af42a3eb24e378a89aa.png differ diff --git "a/\345\225\206\345\223\201\347\256\241\347\220\206\347\263\273\347\273\237cmd.png" "b/\345\225\206\345\223\201\347\256\241\347\220\206\347\263\273\347\273\237cmd.png" new file mode 100644 index 0000000000000000000000000000000000000000..a913a682d7a1f040f5abfb529dfa5078d4cbb65a Binary files /dev/null and "b/\345\225\206\345\223\201\347\256\241\347\220\206\347\263\273\347\273\237cmd.png" differ diff --git "a/\346\236\227\346\231\227\345\270\214/20240903 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\344\275\234\344\270\232.md" "b/\346\236\227\346\231\227\345\270\214/20240903 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..b32a47222c2fb9e20be978558cc78d7344b48209 --- /dev/null +++ "b/\346\236\227\346\231\227\345\270\214/20240903 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\344\275\234\344\270\232.md" @@ -0,0 +1,105 @@ +![输入图片说明](../%E5%95%86%E5%93%81%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9Fcmd.png) +代码: + +``` +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2024/9/7 10:30:12 */ +/*==============================================================*/ + + +drop table if exists customer; + +drop table if exists goods; + +drop table if exists including; + +drop table if exists orders; + +drop table if exists users; + +/*==============================================================*/ +/* Table: customer */ +/*==============================================================*/ +create table customer +( + ࠍ֧ۧ۰ int, + ࠍۧѕĻ varchar(255), + ࠍۧєҰ varchar(255), + ࠍۧҠۅ int not null, + uid int, + primary key (ࠍۧҠۅ) +); + +/*==============================================================*/ +/* Table: goods */ +/*==============================================================*/ +create table goods +( + gid int not null, + gname float, + gprice float, + primary key (gid) +); + +/*==============================================================*/ +/* Table: including */ +/*==============================================================*/ +create table including +( + gid int not null, + oid int not null, + primary key (gid, oid) +); + +/*==============================================================*/ +/* Table: orders */ +/*==============================================================*/ +create table orders +( + oid int not null, + ࠍۧҠۅ int, + uid int, + oprice float, + cmessage varchar(255), + primary key (oid) +); + +/*==============================================================*/ +/* Table: users */ +/*==============================================================*/ +create table users +( + uid int not null, + ࠍۧҠۅ int, + uname varchar(255), + upsw varchar(255), + primary key (uid) +); + +alter table customer add constraint FK_manage2 foreign key (uid) + references users (uid) on delete restrict on update restrict; + +alter table including add constraint FK_including foreign key (gid) + references goods (gid) on delete restrict on update restrict; + +alter table including add constraint FK_including2 foreign key (oid) + references orders (oid) on delete restrict on update restrict; + +alter table orders add constraint FK_order foreign key (ࠍۧҠۅ) + references customer (ࠍۧҠۅ) on delete restrict on update restrict; + +alter table orders add constraint FK_responsible foreign key (uid) + references users (uid) on delete restrict on update restrict; + +alter table users add constraint FK_manage foreign key (ࠍۧҠۅ) + references customer (ࠍۧҠۅ) on delete restrict on update restrict; + +``` + +简单查询: +``` +SELECT * FROM goods; + +SELECT gprice FROM goods WHERE gid=2; +```