随笔分类 - SQL
SQL学习
摘要:设计规范: 1.采用有意义的字段名 尽可能地把字段描述的清楚些。当然,也别做过头了,比如CustomerShippingAddressStreetLine1虽然很富有说明性,但没人愿意键入这么长的名字,具体尺度就在你的把握中。首个字母小写,多个单词的话,每个单词的首个字母要求用大写!不要用下...
阅读全文
摘要:--读取库中的所有表名select name from sysobjects where xtype='u'--读取指定表的所有列名select name from syscolumns where id=(select max(id) from sysobjects where xtype='u'...
阅读全文
摘要:create procedure proc_page_withtopmax( @pageIndex int,--页索引 @pageSize int,--每页显示数 @pageCount int output,--总页数,输出参数 @totalCount int output--总条数)asbegi...
阅读全文
摘要:算差月1.select trunc(sysdate) , months_between(trunc(sysdate, 'mm'), trunc(to_date( '2011-2-17', 'YYYY-MM-DD'), 'mm')) from dual2.算差天select trunc(sysdate-to_date('2011-3-10','yyyy-mm-dd')) from dual;3算本月最后一天select trunc(sysdate, 'MONTH') 本月第一天,to_
阅读全文
摘要:--从一个表中随机取两条记录--1.dbms_random.valueselect * from(select * from t_ums_config order by dbms_random.value) where rownum <= 2;--2.dbms_random.randomselect * from(select * from t_ums_config order by dbm...
阅读全文