-- ********** create database ********** --
-- ********** Begin ********** --
create database school-- ********** End ********** --
gouse school
go-- ********** create table ********** --
-- ********** Begin ********** --
create table teacher(ID int not NULL,Name varchar(20) not NULL,sex char(2) not NULL,Phone varchar(20) NULL
)-- ********** End ********** --
goSET NOCOUNT ON-- ********** insert ********** --
-- ********** Begin ********** --
insert into teacher(ID,Name,sex,Phone
)
values('1','Lucy','F',NULL
)-- ********** End ********** --
go
上述答案正确,但这里我有一个问题,ID为int类型但是这里并不能不加单引号
-- ********** create database ********** --
-- ********** Begin ********** --
create database website-- ********** End ********** --
gouse website
go-- ********** create table ********** --
-- ********** Begin ********** --
create table shopping(ID int identity(1,1) not NULL,// idtntity(1,1)从一开始自增Name varchar(20) not NULL,//identity(a,b)a为初值,b为增幅address varchar(30) not NULL
)-- ********** End ********** --
goSET NOCOUNT ONinsert into shopping (Name, address) values ('eBay', 'www.ebay')
goSET NOCOUNT ON-- ********** insert ********** --
-- ********** Begin ********** --
insert into shopping (Name, address) values ('amazon', 'www.amazon')-- ********** End ********** --
goSET NOCOUNT ON-- ********** delete ********** --
-- ********** Begin ********** --
delete from shopping where Name='eBay'-- ********** End ********** --
go
indetity(a,b)
a为初值,b为增幅
-- ** create database ** --
-- ** Begin ** --
create database Books-- ** End ** --
gouse Books
go-- ** create table ** --
-- ** Begin ** --
create TABLE prices(ID int IDENTITY(1,1) not null,Name varchar(20) not null,price varchar(30) not null)-- ** End ** --
goSET NOCOUNT ON-- ** insert ** --
-- ** Begin ** --insert into prices (Name, price) values ('Harry Potter', '$128')-- ** End ** --
goSET NOCOUNT ONinsert into prices (Name, price) values ('Walden', '$5')
goSET NOCOUNT ON-- ** update ** --
-- ** Begin ** --
update prices
set price = '$6'
where Name = 'Walden'-- ** End ** --
go
本文发布于:2024-01-31 06:18:39,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170665312026150.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |