SQL 初级考试题目 ,求大神解答,谢谢啦,要求截图252837523 拜托, 好人一生平安 10
3个回答
展开全部
1.创建数据库
create database xsgl on primary(
name='xsgl_data',
filename='D:\sqlwork\xsgl_data.mdf',
size=10,
maxsize=30,
filegrowth=10%)
Log on
(name=xsgl_log,
filename='D:\sqlwork\xsgl_log.ldf',
size=2,
maxsize=8,
filegrowth=1
)
2建表
create table salersInfo
(
SalerID nchar(5) primary key,
Selername nvarchar(8) not null,
Sex nchar(1),
Birthday datetime,
HireDate datetime,
Adress nvarchar(50),
Telephone nvarchar(15),
Note nvarchar(300)
)
create table CustomersInfo
(
CustomerID nchar(5) primary key,
CompanyName nvarchar(60),
Contactname nvarchar(8),
CompanyAddress nchar(60),
Postcode nchar(6),
Telephone nvarchar(15)
)
create table ProductsInfo
(
ProductID nchar(8) primary key,
ProductName nvarchar(20),
CategoryID nchar(8) foreign key references CategoriesInfo(CategoryID),
Price money,
stockNumber int
)
create table CategoriesInfo
(
CategoryID nchar(8) primary key,
CategoryName nvarchar(30),
Description nvarchar(40)
)
create table OrdersInfo
(
OrderID nchar(5) primary key,
CustomerID nchar(5),
SalerID nchar(5),
Orderdate datetime
)
create table OrdersDlsetailsInfo
(
OrderID nchar(5) foreign key references OrdersInfo(OrderID),
ProductID nchar(8) foreign key references ProductsInfo(ProductID),
Quantity Int,
primary key(OrderID,ProductID)
)
3
(1)
alter table salersInfo
add IDcard nvarchar(16)
(2)
alter table salersInfo
alter column IDcard nvarchar(18)
(3)
alter table CategoriesInfo
add default ('毛衣') for CategoryName with values
4
(1)
create index index_kk on CustomersInfo(Postcode desc)
(2)
sp_helpindex CustomersInfo
(3)
drop index index_kk on CustomersInfo
5
insert into salersInfo(SalerID,Selername,Sex,Birthday,HireDate,Adress,Telephone)
values('00001','王红','女','1985-12-03','2010-11-03','成绵路59号','13999630542')
其它的插入信息也是一样的,都是
insert into 表名(列名1,列名2,列名3,列名4,列名5,列名6,列名7)
values('列名1的值','列名2的值','列名3的值','列名4的值','列名5的值','列名6的值','列名7的值')
整型字段不加单引号
也可以
insert into salersInfo
values('00001','王红','女','1985-12-03','2010-11-03','成绵路59号','13999630542','','')
插入的字段值与数据库中的字段顺序要一致,字段为空的也要插入''
insert into 表名
values('列名1的值','列名2的值','列名3的值','列名4的值','列名5的值','列名6的值','列名7的值','列名8的值','列名9的值')
6
(1)
Update salersInfo set Selername='吴红霞' where SalerID='00002'
(2)
insert into ProductsInfo
values('01000018','天奴长袖','t000003',450,100)
(3)
delete from ProductsInfo where ProductName Like '%天奴%'
(4)
Update CustomersInfo set CompanyAddress ='游仙路36号' where CompanyAddress Like '%仙人路%'
(5)
Update ProductsInfo set Price =Price+(Price*0.1)
create database xsgl on primary(
name='xsgl_data',
filename='D:\sqlwork\xsgl_data.mdf',
size=10,
maxsize=30,
filegrowth=10%)
Log on
(name=xsgl_log,
filename='D:\sqlwork\xsgl_log.ldf',
size=2,
maxsize=8,
filegrowth=1
)
2建表
create table salersInfo
(
SalerID nchar(5) primary key,
Selername nvarchar(8) not null,
Sex nchar(1),
Birthday datetime,
HireDate datetime,
Adress nvarchar(50),
Telephone nvarchar(15),
Note nvarchar(300)
)
create table CustomersInfo
(
CustomerID nchar(5) primary key,
CompanyName nvarchar(60),
Contactname nvarchar(8),
CompanyAddress nchar(60),
Postcode nchar(6),
Telephone nvarchar(15)
)
create table ProductsInfo
(
ProductID nchar(8) primary key,
ProductName nvarchar(20),
CategoryID nchar(8) foreign key references CategoriesInfo(CategoryID),
Price money,
stockNumber int
)
create table CategoriesInfo
(
CategoryID nchar(8) primary key,
CategoryName nvarchar(30),
Description nvarchar(40)
)
create table OrdersInfo
(
OrderID nchar(5) primary key,
CustomerID nchar(5),
SalerID nchar(5),
Orderdate datetime
)
create table OrdersDlsetailsInfo
(
OrderID nchar(5) foreign key references OrdersInfo(OrderID),
ProductID nchar(8) foreign key references ProductsInfo(ProductID),
Quantity Int,
primary key(OrderID,ProductID)
)
3
(1)
alter table salersInfo
add IDcard nvarchar(16)
(2)
alter table salersInfo
alter column IDcard nvarchar(18)
(3)
alter table CategoriesInfo
add default ('毛衣') for CategoryName with values
4
(1)
create index index_kk on CustomersInfo(Postcode desc)
(2)
sp_helpindex CustomersInfo
(3)
drop index index_kk on CustomersInfo
5
insert into salersInfo(SalerID,Selername,Sex,Birthday,HireDate,Adress,Telephone)
values('00001','王红','女','1985-12-03','2010-11-03','成绵路59号','13999630542')
其它的插入信息也是一样的,都是
insert into 表名(列名1,列名2,列名3,列名4,列名5,列名6,列名7)
values('列名1的值','列名2的值','列名3的值','列名4的值','列名5的值','列名6的值','列名7的值')
整型字段不加单引号
也可以
insert into salersInfo
values('00001','王红','女','1985-12-03','2010-11-03','成绵路59号','13999630542','','')
插入的字段值与数据库中的字段顺序要一致,字段为空的也要插入''
insert into 表名
values('列名1的值','列名2的值','列名3的值','列名4的值','列名5的值','列名6的值','列名7的值','列名8的值','列名9的值')
6
(1)
Update salersInfo set Selername='吴红霞' where SalerID='00002'
(2)
insert into ProductsInfo
values('01000018','天奴长袖','t000003',450,100)
(3)
delete from ProductsInfo where ProductName Like '%天奴%'
(4)
Update CustomersInfo set CompanyAddress ='游仙路36号' where CompanyAddress Like '%仙人路%'
(5)
Update ProductsInfo set Price =Price+(Price*0.1)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这些SQL都是最基础的,百度随便一搜一大把
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你用的什么数据库?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询