随笔分类 - SQL
摘要:SELECT des.program_name , des.login_name , des.host_name , COUNT(des.session_id) [Connections]FROM sys.dm_exec_sessions desINNER JOIN sys.dm_exec_conn
阅读全文
摘要:对各种连接的理解,可以参照文章。 下面是对连接结果表条数统计的思考:假设有主表Ta有5条记录,从表Tb有4条记录 Ta corss join Tb, 结果为2表做笛卡尔积,5*4=20条 /*下面其它连接返回的结果都是cross join的子集*/ Ta inner join Tb, 结果分为有重复
阅读全文
摘要:1. 尽可能把数据的存储和计算放入Memory而不是Disk,且减少IO操作,比如运用Redis等缓存技术 2. 对数据表进行精心设计,特别是大数据表,对常用数据字段进行适当的冗余,尽可能避免分表导致的Join查询,即使非Join不可也是大表和小表Join,而不是一堆大表之间Join 3. 对常用查
阅读全文
摘要:CREATE TABLE COBRA.COBRA_PRODUCT_INFO_BAK AS SELECT * FROM COBRA.COBRA_PRODUCT_INFO; TRUNCATE TABLE COBRA.COBRA_PRODUCT_INFO; ALTER TABLE COBRA.COBRA_
阅读全文
摘要:为了防止数据被错误修改例如商品库存被改为-1如何加锁,应该加什么锁,相应的机制是什么
阅读全文
摘要:In some case, we found that when we execute the sql commands like truncate table, drop table, delete all records in table, join 2 tables, it will take
阅读全文
摘要:If a table have column A and B Count(distinct A) as Da Count(distinct B) as Db Count(distinct A, B) as Dab The Da/Db<=Dab, this will be always true; 1
阅读全文
摘要:If you don't have the permission to generate script according to an existing db, but you have the read permission for that db, if so you can use selec
阅读全文
摘要:https://zh.wikipedia.org/wiki/Redis http://www.jianshu.com/p/01b37cdb3f33
阅读全文
摘要:How to solve the VS installed machine cannot run performance testing by .testsettings file, which will distribute the tests running on multiple test a
阅读全文
摘要:Same:delete/truncate/drop, all of them can support rollback/commit, the sample is as below:begin tran T1truncate table TestTablerollback/commitDiffere...
阅读全文

浙公网安备 33010602011771号