几个常用的sql语句(续)

来源:互联网 发布:努比亚z17 预装软件 编辑:程序博客网 时间:2024/05/16 15:55

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)

    

    好,先总结到这儿!

原创粉丝点击