文档库 最新最全的文档下载
当前位置:文档库 › 2 常用的SQL语句

2 常用的SQL语句


1、update语句
update语句允许用户在已知的表中对现有的行进行修改。

 update employee
set ab = 'New York'
where ab = 'Boston'


2、insert语句
1)、 insert into employee
values ('Smith','1980-06-10', 'Los Angles',16,45000,NULL)

注意:a、整型十进制数都不需要用单引号引起来,而字符串和日期类型的值都要用单引号来区别。
b、在SQL中逗号‘,’是元素的分隔符。
c、输入文字值时要使用单引号‘ ’;
双引号“”用来封装限界标识符;
问号 ? 是占位符;
d、NULL不要引号,

2)、insert into employee (FIRST_NAME, LAST_NAME, HIRE_DATE, BRANCH_OFFICE)
values ('Smith','1980-06-10', '1992-02-01','Indianapolis')



3、select语句

select invioid_seq.nextval from dual
select * from i_ioheader
select * from i_iodetail


4、delete语句
delete employee
where ab = 'Los Angeles'





1、查询状态汇总表b_typesdata
select distinct * from b_typesdata where typesname='taskstate'

select distinct * from b_typesdata where typesname='iotype'


2、 select part_number,drawingid from b_part_number

3、查询工序任务
select t.operation_iddesc,
t.taskstate,
t.planqty,
b.drawingid,
t.batchnum,
t.*
from t_tasks t
inner join b_part_number b on b.part_number = t.part_number
where b.drawingid = 'ZG1-34-001'
and t.batchnum = '1P0903'
and t.operation_iddesc ='105'
and t.tasktype like '1%'
order by t.operation_id
for update

select * from m_checkheader where taskuid='2380651'for update


select t.operation_iddesc,
t.taskstate,
t.*
from t_tasks t
inner join b_part_number b
on b.part_number = t.part_number
and t.batchnum = upper('20s1001')
and b.drawingid = 'LCS1-1120-03'
order by t.operation_id for update




select invioid_seq.nextval from dual



select * from i_ioheader

select * from b_part_number

select * from t_task_part

select relationid from i_iodetail

select * from i_iodetail

select i.warehouseid,i.iotype,i.deptid,d.customer_deptid,i.deptemp,i.creator,i.createtime
from i_ioheader i
left join r_dept d on i.deptid=d.deptid
where i.invioid='19619'

select i.seq, i.part_number, t.customer_name, t.drawingid, i.applyqty,i.uom,t.model
from i_iodetail i
inner join tv_task_part t on i.relationid=t.unique_id
where i.invioid='19619'


相关文档