W~C停用

导航

随笔分类 -  Sql相关

Sql语句的优化
摘要:1)SELECT 子句中避免使用 “*” 当你想在 SELECT 子句中列出所有的 columns 时,使用动态 SQL 列引用‘*’是一个方便的方法。不幸的是,这是一个非常低效的方法。 实际上,Oracle 在解析的过程中, 会将“*” 依次转换成所有的列名, 这个工作是通过查询数据字典完成的, 阅读全文

posted @ 2022-04-15 10:41 W~C停用 阅读(74) 评论(0) 推荐(0)

sql 添加为空不重复的索引
摘要:CREATE UNIQUE NONCLUSTERED INDEX un_CompanyInfo_FK_CompanyId ON dbo.CompanyInfo(FK_CompanyId) WHERE FK_CompanyId is not null GO 阅读全文

posted @ 2021-07-03 18:07 W~C停用 阅读(94) 评论(0) 推荐(0)

创建一个储存过程
摘要:--公司注册 if exists(select * from Sysobjects where name='usp_CompanyRegister') drop procedure usp_CompanyRegister; go create procedure usp_CompanyRegiste 阅读全文

posted @ 2021-06-26 16:12 W~C停用 阅读(20) 评论(0) 推荐(0)

根据月份查询
摘要:SELECT * FROM dbo.CheJianSegmentation WHERE CONVERT(VARCHAR(7),AddTime,120)=CONVERT(VARCHAR(7),@AddTime,120) 阅读全文

posted @ 2021-05-28 10:37 W~C停用 阅读(38) 评论(0) 推荐(0)

Sql一个简易的登录事务
摘要:use MustGoHome; --判断该事物是否存在,存在就删除 if exists(select * from Sysobjects where name='usp_UserLogin') drop procedure usp_UserLogin; GO--/创建登录事物 create proc 阅读全文

posted @ 2021-05-16 18:43 W~C停用 阅读(98) 评论(0) 推荐(0)

一个通用的SQL语句
摘要:if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sys_Page_v2]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo]. 阅读全文

posted @ 2021-05-09 20:04 W~C停用 阅读(81) 评论(0) 推荐(0)

Sql语句注册公司的事务
摘要:use MustGoHome; --公司注册 if exists(select * from Sysobjects where name='usp_CompanyRegister') drop procedure usp_CompanyRegister; go create procedure us 阅读全文

posted @ 2021-05-03 18:43 W~C停用 阅读(97) 评论(0) 推荐(0)

清除数据库中所有表的数据,不删除表
摘要:declare c cursor for select NAME from sysobjects where xtype='U' declare @t varchar(200) open c fetch next from c into @t while @@FETCH_STATUS=0 begin 阅读全文

posted @ 2021-04-26 14:41 W~C停用 阅读(250) 评论(0) 推荐(0)

不删除库,删除库中所有表
摘要:USE 库名 GO sp_msforeachtable'drop table?' GO 阅读全文

posted @ 2021-04-22 09:40 W~C停用 阅读(58) 评论(0) 推荐(0)