.....

一、informix
a、文件处理
 --cp  FZ00.FZ0020.000120048466.1.trs /tmp   --下载到/tmp目录
 --cd /tmp
 --unzip FZ00.FZ0020.000120048466.1.trs      --解压文件
 --cat FZ00.FZ0020.000120048466.1.dat        --查看文件内容
 --cat 查看
 --vi 编辑 :q!退出编辑
 --ls -l -h YH00.VSS.000101762975.1.trs   --查看文件大小
 --mv FZ00PF.FZ00.000100007064.1.dat /history --移动文件

 --su - bmjob 用户名     --用户切换
b、删除带参数的存储过程
 drop  procedure RPT_GoodsSaleSum(date,date,int,varchar(10), int,varchar(15))

 导存储过程命令:
 dbschema -d dbdms -f st_fpoaskration

c、锁表
 查看资源占用
 set isolation to dirty read;
 DATABASE sysmaster;
 select * from syssessions
 ---
 select * from sysmaster:syslocks
 --独占锁表
 --begin work;
 --  lock table venderdiscrpt in exclusive mode;
 --  delete from venderdiscrpt;
 --commit

 onstat -u  查看用户
 onmode -z sessid 把其它人踢掉。
 用oncheck -cI 数据库名进行检查,如果发现有锁表现象,
      用who -u找见进此用户的进程号,
      用ps -ef|grep  pts/??
      用kill -9 进程号  进程号

d、存储过程语句
 select * from sysprocedures a,sysprocbody b
 where datakey="T" and a.procid=b.procid and a.procname=lower("io_purchaseask_to")

e、索引最好分开建到10个索引空间中,有利于io均衡.
   建索引前用以下sql查询各数据空间的使用率,索引建到可用空间多的数据空间中.

 select name dbspace,sum(chksize) allocated,sum(nfree) free, round(((sum(chksize)-sum(nfree))/sum(chksize))*100)||"%" pcused
 from sysdbspaces d,syschunks c
 where d.dbsnum=c.dbsnum group by name order by 4 desc

 if not exists(select 1 from  systables a,syscolumns b where a.tabid=b.tabid and a.tabname=lower('goodsshop')  and  b.colname='activeflag' ) then
  alter table goodsshop add activeflag int default 1 ;
 end if
 -------SQLServer增加表结构-----------
 if not exists (select * from sysobjects a,syscolumns b where a.id=b.id and a.name='RPT_GoodsProffer' and b.name='maolizb')
  alter table RPT_GoodsProffer add  maolizb          decimal(15,4)

 --索引
 SELECT a.tabname, b.colname, c.idxname FROM systables a, syscolumns b, sysindexes c
 WHERE a.tabid = b.tabid AND a.tabid = c.tabid AND b.colno = c.part1 and a.tabname like lower('%user_list%');

 select * from sysindices where idxname in
 (select idxname  from sysindexes a,systables b where a.tabid = b.tabid and tabname like lower('%goodsshop%'))

f、改表名>RENAME TABLE oldname TO newname
   alter table 表名 modify (字段名 新类型)
   ALTER TABLE TABLENAME ADD/DROP/MODIFY COLUMNNAME TYPE
   如果你想跨事务使用游标,只能with hold

g、删除索引:
   DROP INDEX index_name

   删除主键:
   alter  table  tabname  drop  constraint  cons_name;

   修改informix数据库表的主键,需要首先删除主键,再新建。
  第一步:
  查出该主键的约束的名字,查约束名SQL语句如下(TabName为表名):
 SELECT constrname FROM sysconstraints
 WHERE tabid = (SELECT tabid FROM systables WHERE lower(tabname)=lower('TabName') ) and constrtype ='P' ;
 {
  constrtype ='P' 是主键约束, 还有C 检查(Check)R 引用(外键)(Reference,Foreign Key) U 唯一 *** (Unique) N 非空(Not Null)
 }

 SELECT a.tabname, b.colname, c.idxname FROM systables a, syscolumns b, sysindexes c
 WHERE a.tabid = b.tabid AND a.tabid = c.tabid AND b.colno = c.part1 and a.tabname like lower('%user_list%');

  第二步:
 删除主键(TabName为表名,u144_58为上一步查出的约束名),SQL语句如下:
 alter table TabName drop constraint u144_58;

  第三步:
 新建主键(主键为policyno,classcode,loandate),SQL语句如下:
 ALTER TABLE TabNameADD CONSTRAINT PRIMARY KEY (policyno,classcode,loandate) CONSTRAINT u144_58;{u144_58约束名可自定,必需唯一}

h、时间
 datetime year to second default current year to second : 具体到时分秒
 current + interval(30) minute to minute:当前时间加30分钟
        current year to day - interval(7) day to day:当前日期减7天
 To_char(current,'%Y%m%d%H%M%S'):20100401105737
 to_char(date(current)+1,'%Y-%m-%d')||' 03:40:00', to_char(today+1,'%Y-%m-%d')||' 03:40:00'

i、Update
  FOREACH Cur_OrderAdvice WITH HOLD FOR
   SELECT GoodsID,ShopID INTO __GoodsID,__ShopID FROM Tmp_OrderAdviceGoods_0
   
 LET __BreakPoint = 8207200;
   update Tmp_OrderAdvice set (intendstockday, safestockday, maxstockday, adviceflag)=
         ((select intendstockday, safestockday, maxstockday, adviceflag from OrderAdvice
           where goodsid = __GoodsID and shopid = __ShopId))
   where goodsid = __GoodsID and shopid = __ShopId;
   
  END FOREACH;
  Update GSaleFlag set (Flag,Checker,CheckDate)=(100,__Checker,current) where SheetID=__SheetID and Flag=0;

j、select count(*) into __iCnt from sysProcedures where procname=lower(__sOBJName);
    if object_id('tempdb..#Tmp_CPDGoodsItem') is not null drop table #Tmp_CPDGoodsItem; --SQL临时表

k、触发器
 ----机构变化时触发下传数据
 --drop trigger tr_UserSystem_Ins;
 create trigger tr_UserSystem_Ins Insert on User_System
  referencing new as a for each row
  (insert into USysChgURole_PDA0(shopid,userid,roleid,Modiattr,Modiopid) values(a.shopid,a.userid,'','A','')) 
  after (execute procedure SYN_PDA_USysChgURole('','','ins'))

 --drop trigger tr_UserSystem_del;
 create trigger tr_UserSystem_del Delete on User_System
  referencing old as a for each row
  (insert into USysChgURole_PDA0(shopid,userid,roleid,Modiattr,Modiopid) values(a.shopid,a.userid,'','D','')) 
  after (execute procedure SYN_PDA_USysChgURole('','','del'))

二、SQLServer

三、C#
a. 日期
  DateTime dt = DateTime.Parse(e.EditValue);
  DateTime startMonth = dt.AddDays(1 - dt.Day);  //当月第一天
  DateTime endMonth = startMonth.AddMonths(1).AddDays(-1);  //当月最后一天
  if (!dt.Equals(endMonth))
  {
   rsDateEdit2_2.EditValue = Convert.ToString(endMonth);
  }
b. String.Format('{0:f3}',变量)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值