随笔分类 - 数据库
摘要:WITH FINISHMAINT (FRAMENO,DELIVEREDDATE) AS(SELECT DISTINCT RP.FRAMENO, MAX(PRC.DELIVEREDDATE) OVER(PARTITION BY RP.FRAMENO) FROM RT_REPAIR RP LEFT JO...
阅读全文
摘要:一、前言 虽然我们大多数人都学习过SQL,但是经常忽略它。总是会自以为学到的已经足够用了,从而导致我们在实际开发的过程中遇到复杂的问题后只能在检索数据后通过传统的代码来完成,但是其中很多的功能利用SQL就可以轻松的办到,所以我们开始重视SQL,它的地位不亚于C#,javascript。二、目录 ...
阅读全文
摘要:ALTER TABLE CM_STAFF ALTER FULLNAME SET DATA TYPE VARCHAR(50);
阅读全文
摘要:DB2—alter追加/删除/重置column操作1.添加字段alter table 表名称 add 字段名称 类型Demo:1alter table table_name add column_test VARCHAR(50);2. 更改字段类型alter table 表名称 alter colu...
阅读全文
摘要:DROP TRIGGER TR_MONTHLYCLOSING;CREATE TRIGGER TR_MONTHLYCLOSING NO CASCADE BEFOREINSERT ON PT_MONTHLYCLOSING REFERENCING NEW AS NEWROWFOR EACH ROW MOD...
阅读全文
摘要:ALTER TABLE PT_MONTHLYCLOSING ADD TESTCOL VARCHAR(50) DEFAULT '2004'
阅读全文
摘要:一、查询表主键。describe indexes for table .例:describe indexes for table db2inst1.aaa二、删除表主键。alter table . drop primary key例:alter table db2inst1.aaa drop pri...
阅读全文
摘要:时间加减:后边记得跟上时间类型如day、HOURTIMESTAMP ( TIMESTAMP(DEF_TIME)+1 day)+18 HOURDB2时间函数是我们最常见的函数之一,下面就为您介绍一些DB2时间函数,供您参考,希望可以让您对DB2时间函数有更多的了解。--获取当前日期:select cu...
阅读全文
摘要:WITH TMP_EXECUTOR(EXECUTOR,EXECUTORNAME) AS ( SELECT DISTINCT T.EXECUTOR ,T1.FULLNAME AS EXECUTORNAMEFROM (SELECT DISTINCT T1.TASKID , T2.EXE...
阅读全文
摘要:Insert是T-sql中常用语句,Insert INTO table(field1,field2,...) values(value1,value2,...)这种形式的在应用程序开发中必不可少。但我们在开发、测试过程中,经常会遇到需要表复制的情况,如将一个table1的数据的部分字段复制到t...
阅读全文
摘要:select count(1) from syscolumns where id = object_id('tbname')或者select * from syscolumns where id = object_id('tbname')或SELECT MAX(colid) FROM syscolu...
阅读全文
摘要:SELECT 0 AS ID, T1.CUSTOMERNAME AS CUSTOMERNAME, T.CUSTOMERLEVEL AS CUSTOMERLEVEL, '续保招揽' A...
阅读全文
摘要:SELECT T1.FRAMENO, T1.UNDERTAKER10,T1.STATUSCODEDATE10, MAX(T1.STATUSCODEDATE10) OVER(PARTITION BY T1.FRAM...
阅读全文
摘要:SELECT T1.REPAIRNO, T1.UNDERTAKER10, T3.FULLNAME AS RECEIVERNAME, T1.WALKDISTANCE, T1.STATUSCODEDATE10 AS RECEIVETIM...
阅读全文
摘要:select CASE WHEN T1.COMMERCIALENDDATE IS NULL THEN T1.INSURANCEMATURITYDATE WHEN YEAR(T1.COMMERCIALENDDATE) = 2014 THEN T1.COMMERCIALENDDATE WHEN...
阅读全文
摘要:alter table RT_InsuranceBuy add column GipInsurerCode CHAR(2);alter table RT_InsuranceBuy add column ImportFlag CHAR(1);
阅读全文
摘要:菜单id = 7的菜单项所拥有的按钮项SELECT T1.*, TT.BUTTONID, TT.NAMEFROM TBBUTTON T1 LEFT JOIN (SELECT * FROM TBMENUBUTTON T2 LEFT JOIN TBMENU T3 ON T2.MENUID = T3.ID...
阅读全文
摘要:1、SQL Server版本:第一步,首先要建立与数据库的连接,方法较多,这里举个例子:http://www.cnblogs.com/netsql/archive/2010/05/17/1737548.html第二个,打开PD15,新建一个PDM文档,然后新建一个表,如图所示:第3步:打开T_ID列...
阅读全文
摘要:解决办法:cd /home/db2inst1/sqllib/bnddb2 bind @db2cli.lst blocking all grant public sqlerror continue CLIPKG 30
阅读全文