几个常用的sql语句(续)

1.delete from project where name is null and description is null;  

    //is null example

2.alter table user add column ip varchar(15) after last_name;     

   //add column example

3.alter table project add column user_id int after project_id;      

4.alter table project add constraint FK_project_ref_user foreign key (user_id)
      references user (user_id) on delete restrict on update restrict;

   //add foreign key by powerdesigner

5.insert into modify_log_type values(11, 40, 'Meeting', NOW(),NOW(),0); 

   //using now():current time

6.update modify_log set plan_time=plan_time*60;             

  // change plan_time(hours) into minutes.

   (Here,we will notice that if plan_time is 2.5hours, it will be changed 150minutes. that's right!!!)

7.alter table user modify password varchar(50);          

   //"modify" key is used to change column type.

   ("change" key has also the same function , and it can change column name. see sql manual.)

8.update modify_log set finish_time=replace(finish_time, ':', ':'); 

  //replace function                

  (Here, we can replace Chinese colon with english colon)

    

    好,先总结到这儿!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值