在数据库中创建数据表时,根据旧表创建新表的Sql怎么写?
1个回答
展开全部
楼主真懒,
这些东西百度一下都有的:
execute
sp_configure'show
advanced
options',1
reconfigure
execute
sp_configure
'xp_cmdshell',1
reconfigure
execute
xp_cmdshell
'mkdir
e:\aaa'
execute
sp_configure
'xp_cmdshell',0
reconfigure
execute
sp_configure
'show
advanced
options',0
reconfigure
--
创建数据库
impression
create
database
impression
on
primary
(
name
=
'impression',
filename
=
'e:\aaa\impression.mdf',
size
=
5,
maxsize
=
unlimited,
filegrowth
=
5
)
log
on
(
name
=
'impression_log',
filename
=
'e:\aaa\impression_log.ldf',
size
=
1,
maxsize
=
unlimited,
filegrowth
=
10%
)
go
--
创建
teacher
表
create
table
teacher
(
id
int
identity(1,1),
name
nvarchar(30),
sex
bit,
birthday
date,
telephone
nvarchar(15),
address
nvarchar(100),
email
nvarchar(100)
)
go
--
给表teacher添加,邮编
字符类型,长度6一列
alter
table
teacher
add
zipcode
nvarchar(6)
go
--
给表teacher
,字段id添加主键
alter
table
teacher
add
constraint
pk_id
primary
key
(id)
go
--
创建索引i_teacher,优化字段email和address
create
index
i_teacher
on
teacher
(email,address)
go
--
创建v_teacher视图
???
这个问题没有规定视图中有什么列啊?
create
view
v_teacher
as
(
select
*
from
teacher
)
go
--
删除id字段主键
alter
table
teacher
drop
constraint
pk_id
--
删除索引i_teacher
drop
index
i_teacher
on
teacher
--
删除视图v_teacher
drop
view
v_teacher
--
删除表teacher
drop
table
teacher
--
删除数据库impression
drop
database
impression
这些东西百度一下都有的:
execute
sp_configure'show
advanced
options',1
reconfigure
execute
sp_configure
'xp_cmdshell',1
reconfigure
execute
xp_cmdshell
'mkdir
e:\aaa'
execute
sp_configure
'xp_cmdshell',0
reconfigure
execute
sp_configure
'show
advanced
options',0
reconfigure
--
创建数据库
impression
create
database
impression
on
primary
(
name
=
'impression',
filename
=
'e:\aaa\impression.mdf',
size
=
5,
maxsize
=
unlimited,
filegrowth
=
5
)
log
on
(
name
=
'impression_log',
filename
=
'e:\aaa\impression_log.ldf',
size
=
1,
maxsize
=
unlimited,
filegrowth
=
10%
)
go
--
创建
teacher
表
create
table
teacher
(
id
int
identity(1,1),
name
nvarchar(30),
sex
bit,
birthday
date,
telephone
nvarchar(15),
address
nvarchar(100),
nvarchar(100)
)
go
--
给表teacher添加,邮编
字符类型,长度6一列
alter
table
teacher
add
zipcode
nvarchar(6)
go
--
给表teacher
,字段id添加主键
alter
table
teacher
add
constraint
pk_id
primary
key
(id)
go
--
创建索引i_teacher,优化字段email和address
create
index
i_teacher
on
teacher
(email,address)
go
--
创建v_teacher视图
???
这个问题没有规定视图中有什么列啊?
create
view
v_teacher
as
(
select
*
from
teacher
)
go
--
删除id字段主键
alter
table
teacher
drop
constraint
pk_id
--
删除索引i_teacher
drop
index
i_teacher
on
teacher
--
删除视图v_teacher
drop
view
v_teacher
--
删除表teacher
drop
table
teacher
--
删除数据库impression
drop
database
impression
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询