文章目录
编程要求
在右侧补全语句,具体编程任务是:
- 补全右侧代码片段中 create database 下 Begin-End 区间的代码,用来建立数据库 Books
- 补全右侧代码片段中 create table 下 Begin-End 区间的代码,用来建立空表 prices ,其中表结构如下图所示:
- 补全右侧代码片段中 insert 下 Begin-End 区间的代码,用来插入内容 Harry Potter ,具体内容如下表所示: (我们已经事先帮你插入了内容 Walden ,所以你只要关注 Harry Potter 的插入即可)
提示:
如果我们使用语句:
create TABLE prices
(
ID int IDENTITY(1,1) not null
)
会使字段 ID 的数字自增。本关要求同学们使用该语句,但同学们插入内容的时候请不要给字段 ID 赋值,因为它自己会自增!
代码块部分为需要填入的答案
– ********** create database ********** –
– ********** Begin ********** –
create database Books;
– ********** End ********** –
go
use 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 ********** –
go
SET NOCOUNT ON
– ********** insert ********** –
– ********** Begin ********** –
insert into prices (Name, price) values ('Harry Potter','$128')
– ********** End ********** –
go
SET NOCOUNT ON
insert into prices (Name, price) values (‘Walden’, ‘$5’)
go
SET NOCOUNT ON
– ********** update ********** –
– ********** Begin ********** –
update prices set price='$6' where Name='Walden';
– ********** End ********** –
go