- 冷门数据库SQL汇总
- 前言
- 一、冷门而必要的SQL语句
前言
汇总数据库知识
一、冷门而必要的SQL语句1.SQL Server查询所有表名的名称,含Schema架构名,格式:架构名.表名
--查询所有表名的名称,含Schema架构名,格式:架构名.表名
select concat(s.name ,concat('.',t.name)) as tableName
from sys.tables t left join sys.schemas s
on t.schema_id=s.schema_id order by tableName asc;
2.查询当前数据库名称
--查询当前数据库名称 select Name From Master..SysDatabases Where DbId=(Select Dbid From Master..SysProcesses Where Spid = @@spid)
3.SQL Server创建临时表,并把数据写入临时表
if Object_ID('tempdb..#temp1') is not null
drop table #temp1;
Select * into #temp1 from MasterData;
4.昨天
select getdate()-1



