Leo

软件编程技术

导航

SQL备份表及相关笔记

Posted on 2013-08-21 08:53  Leo(binbin)  阅读(232)  评论(0编辑  收藏  举报

create table history1301
(
 remark nvarchar(64)
)
create table history1302
(
 remark nvarchar(64)
)
create table history1303
(
 remark nvarchar(64)
)
create table history1304
(
 remark nvarchar(64)
)

create table history
(
 remark nvarchar(64)
)

insert into history1301(remark) values('history1301');
insert into history1302(remark) values('history1302');
insert into history1303(remark) values('history1303');
insert into history1304(remark) values('history1304');

select * from history1301;
select * from history1302;
select * from history1303;
select * from history1304;
select * from history
--备份表
select * into history1111 from history1301
--插入历史记录

--假如表存在(实用多表多次导入)
insert into history(remark) (select remark from history1301)
insert into history(remark) (select remark from history1302)
insert into history(remark) (select remark from history1303)
insert into history(remark) (select remark from history1304)

--假如不存在(实用单表单次导入)
select * into historyTemp from history1301

--查看用户库中是否存在history表
select * from sys.objects where [type]='U' and name='history'

--查看是否有是否创建数据库实例
select * from sys.sysdatabases  where name='数据库名'

--查看表约束
exec sp_helpconstraint 'history'

exec sp_help 'Account'
exec sp_helpconstraint 'Account'

点击这里给我发消息