oracle用什么语句,oracle常用语句的使用

删除某字段值为空的所有记录

delete from tasks where task_id is Null

同时从两张表里取数据,这个功能真是太强大了,以前一直没留意使用它。

select tasks.id,tasks.subject,tasks.definition,tasks.creator,taskaccessories.label from tasks,taskaccessories where tasks.id=taskaccessories.task_id and tasks.id=347

这是目前我写过最为复杂的一条sql语句

意为从task表中取出id,subject值,并且部门名称是从另一张表中根据id值取出来的。

select id,subject from tasks where department=(select name from taskdepartment where id =".$_SESSION['departid'].") and opentime is not null and assigntime is null

又进一步了。

select id,subject from tasks where id not in(select task_id from taskapplicator where applicator='".$_SESSION['user']."' and applytime is not null ) and department=(select name from taskdepartment where id =".$_SESSION['departid'].") and opentime is not null and assigntime is null");

删除id为348,352,364的数据的记录

delete from taskaccessories where id in(348,352,364)

将时间转化格式为这样:2009-09-17 22:07:24     如果没有加粗的部分,原来的样式为如此的17-SEP-09

select id,subject,department,creator,to_char(opentime,'yyyy-mm-dd hh24:mi:ss') as opentime from tasks where opentime is not null and assigntime is null

选出tasks表中所有的相关信息但不包括id=$_GET['id']

select id,subject from tasks where opentime is not null and assigntime is null and id not in '".$_GET['id']."'

那个关联任务,如果是在A任务里添加了一个B任务做关联,

那么B任务里是不是也要显示下A任务做为他的关联任务的啊。

select id,subject,creator,department from tasks where id in(select relate_id from taskrelation where task_id='290')

union

select id,subject,creator,department from tasks where id in(select task_id from taskrelation where relate_id='290')

select * from quser order by id desc

desc 表示降序,asc表示升序

/*oracle中创建自动编号*/    意为序列号从5开始,因为oracle当中没有自动编号这个功能只能用这样的语句来创建CREATE SEQUENCE seq_taskappraise start with 5 NOMAXVALUE NOCYCLE NOCACHE;

insert into taskappraise(id,task_id,appraiseor,appraise,appraisetime) values(seq_taskappraise.nextval,'290','无159影刀','非常GOOD 168',sysdate)

/*删除一个字段*/

alter table taskappraise drop column score

/*删除多个字段*/

alter table tasks drop (appraise,appraisetime);

/*评分 插入一个字段*/

alter   table   tasks   add   score  number(5)

/*修改一个字段的内容*/

update tasks set definition = '这是新修改的内容' where id =290

/*修改多个的内容*/

UPDATE tasks SET subject = '12134545',definition = '123123132' WHERE id =1

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值