您的位置:首页 > 数据库

几个常用的sql语句(续)

2008-11-08 11:02 204 查看
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)

好,先总结到这儿!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: