練習寫資料庫

2021-08-30 20:57:31 字數 2791 閱讀 7696

create database factorywork

gouse factorywork

gocreate table employee

(employeeid int not null primary key,

employeename char(20) not null,

employee*** char(2) not null,

employeeorder int not null,

employeecallphone int null,

employeeaddress text null

)alter table employee

add constraint df_order default (1) for employeeorder

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('張三',1,'女',198456875,'地府十三層',1)

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('李四',5,'女',5684257,'地府十五層',2)

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('唐僧',3,'男',5454128,'人界唐朝天國',3)

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('豬八戒',6,'男',78454455,'朱家莊',4)

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('孫悟空',8,'男',75214546,'花果山水簾洞',5)

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('觀世音',4,'女',521158,'紫竹林',6)

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('如來佛',15,'男',52545624,'大西天',7)

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('玉帝',20,'男',4244874,'天庭',8)

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('西王母',11,'女',84597125,'崑崙山',9)

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('炎帝',16,'男',3548975,'不周仙山',10)

insert into employee values (11,'死老鬼','男',6,89452447,'迷霧鬼林')

select * into employeeback from employee --where employee*** ='男'

insert into employeeback select * from employee where employee*** =''

select * from employeeback

delete from employee where employeeid>=1 and employeeid <=11

insert into employee (employeename,employeeorder,employee***,employeecallphone,employeeaddress,employeeid) values ('炎帝',16,'男',3548975,'不周仙山',10)

insert into employee values (30,'小李飛刀','男',6,4545,'原始森林')

insert into employee values (31,'一點紅','男',3,454,'秘密絕境')

insert into employee values (32,'神州七号','女',8,4121,'太空站')

alter table employee drop pk__employee__7c8480ae

insert into employee select * from employeeback

select * from employee

use master

go--drop database factorywork

資料庫練習

1 張三 98 北京 111111111 qq.com 2 李四 88 上海 111111111 qq.com 3 王五 78 廣州 111111111 qq.com 4 趙六 68 深圳 111111111 qq.com 5 孫七 58 杭州 111111111 qq.com 6 小紅 48 北京...

資料庫練習

1.第一題 下 begin end 區間的 統計 course表中學分數 credit 大於2的課程門數 2.第二題 下 begin end 區間的 統計所有專業必修課 bt開頭的課程 的學分總數。3.第三題 下 begin end 區間的 按課程類別統計每個類別課程的門數,如課程 bt001,bt...

資料庫練習

分析 學生表 關聯 班級表 被關聯 多對一 課程表 關聯 老師表 被關聯 多對一 學生表 被關聯 成績表 關聯 多對多 建表順序 班級表 學生表 老師表 課程表 成績表 班級表 create table class cid int primary key auto increment,caption...