-- 创建临时表 create table #temp ( id int not null ) --插入数据 insert into #temp values(1) insert into #temp values(2) insert into #temp values(3) insert into #temp values(4) insert into #temp values(5) insert into #temp values(6) -- 查询数据 select * from #temp -- 删除临时表 drop table #temp
临时表与永久表相似,但临时表存储在 tempdb 中,当不再使用时会自动删除。 临时表有两种类型:本地和全局。它们在名称、可见性以及可用性上有区别。本地临时表的名称以单个数字符号 (#) 打头;它们仅对当前的用户连接是可见的;当用户从 SQL Server 实例断开连接时被删除。全局临时表的名称以两个数字符号 (##) 打头,创建后对任何用户都是可见的,当所有引用该表的用户从 SQL Server 断开连接时被删除。
SQL Server ?1. 操作 临时表 ,与操作普通表几乎一样2. 局部临时表一个会话(连接)结束之后,会自动清除, 不需要显示 DROP
create table #temp ( id int not null )insert into #temp values(1); -- 查询数据 select * from #temp -- 删除临时表 drop table #temp
#temp 带#就是临时表,#order,#123都可以 创建临时表 create table #temp ( id int not null ) 插入数据:insert into #temp values(1) 查询数据:select * from #temp 删除临时表:drop table #temp 去网上一搜一大堆的
CREATE TABLE #temp删除drop table #temp
------------------------
是的,一般用完就drop
create table #temp
(
id int not null
)
--插入数据
insert into #temp values(1)
insert into #temp values(2)
insert into #temp values(3)
insert into #temp values(4)
insert into #temp values(5)
insert into #temp values(6)
-- 查询数据
select * from #temp
-- 删除临时表
drop table #temp
SQL Server ?1.
操作 临时表 ,与操作普通表几乎一样2.
局部临时表一个会话(连接)结束之后,会自动清除, 不需要显示 DROP
(
id int not null
)insert into #temp values(1);
-- 查询数据
select * from #temp
-- 删除临时表
drop table #temp
带#就是临时表,#order,#123都可以
创建临时表
create table #temp
(
id int not null
)
插入数据:insert into #temp values(1)
查询数据:select * from #temp
删除临时表:drop table #temp
去网上一搜一大堆的