当前位置:首页 » 编程语言 » sql例子

sql例子

发布时间: 2023-07-03 19:34:20

A. sql常用语句格式及例子说明是什么呢

如下:

1、创建表:Create table 表名 ( s_id number(4) , s_name varchar2(10) , s_sex char(2) );

2、删除表:Drop table 表名;

3、重命名表名:Rename 旧表名 to 新表名 ;

4、添加列:Alter table 表名 add ( s_age number(3) );

5、删除列:Alter table 表名 drop( S_sex );

6、查询列表所有信息:Select * from 表名 ;

7、查询一个列表信息(加where条件):Select * from 表名 where s_id = 302。

sql创建后表的修改基础用法

添加列 :基本形式:alter table 表名 add 列名 列数据类型 [after 插入位置]。

1、在表的最后追加列 address: alter table students add address char(60); 2、在名为 age 的列后插入列 birthday: alter table students add birthday date after age;

修改列 :基本形式:alter table 表名 change 列名称 列新名称 新数据类型;

1、将表 tel 列改名为 telphone: alter table students change tel telphone char(13) default "-";

2、将 name 列的数据类型改为 char(16): alter table students change name name char(16) not nul。

B. sql查询语句大全

SELECT * FROM TWS2F14CCC260D71 WHERE 地类='1999资源清查有林地'

C. SQL存储过程实例

楼下的太麻烦了吧。emp员工表,输入任何部门号,返回部门的总工资,把总工资和部门好,分别放进emp2表里。
编写存储过程查询某部门员工的工资总和
create or replace procere my_text(v_deptno number)
is
cursor c is select* from emp;
v1 number:=0;
begin
for a in c loop
if(a.deptno=v_deptno) then
v1:=v1+a.sal;
end if;
end loop;
insert into emp2 values(v1,v_deptno);
end;
是不是很吊啊?楼主?

D. sql多表联查实例

sql多表联查实例
下面提供四款sql多表关联查询的实例,个个效率不一样。
select
*
from
order_info
as
a
,ivrlog4ivrdlvinst
as
b
where
(a.saleorder=b.ext1_skill
and
b.start_date=@date1
and
se_id='55'
and
b.ext1_skill!='')
and
convert(varchar(10),a.instime,112)=@date2
and
max(a.instime)
方法二
select
*
from
order_info
as
a
where
a.saleorder=(
select
b.ext1_skill
from
ivrlog4ivrdlvinst
as
b
where
b.start_date=@date1
and
se_id='55'
and
b.ext1_skill!='')
and
convert(varchar(10),max(a.instime),112)=@date2
方法三
declare
@date1
varchar(20),
@date2
varchar(20)
set
@date1='20100812'
set
@date2='2010-08-12'
select
*
from
order_info
as
a
where
a.saleorder=
(select
b.ext1_skill
from
ivrlog4ivrdlvinst
as
b
where
b.start_date=@date1
and
se_id='55'
and
b.ext1_skill!='')
and
convert(varchar(10),a.instime,112)=@date2
and
max(a.instime)
方法四
select
b.caller,
b.start_date,
b.start_time,
b.ext1_skill,
c.deliveryno,
c.destroyresult,
c.deliverydate,
c.deliverytime,
c.arrangetime,
c.driverphone,
c.drivermobile,
a.servicedate,
a.servicetime,
a.workertel
from
order_info
as
a
,ivrlog4ivrdlvinst
as
b
,delivery_info
as
c
where
a.saleorder
in
(select
b.ext1_skill
from
ivrlog4ivrdlvinst
where
b.start_date=@date1
and
b.se_id='55'
and
b.ext1_skill!='')
and
convert(varchar(10),a.instime,112)=@date2
order
by
b.start_date
desc,
b.start_time
desc

热点内容
随机启动脚本 发布:2025-07-05 16:10:30 浏览:515
微博数据库设计 发布:2025-07-05 15:30:55 浏览:19
linux485 发布:2025-07-05 14:38:28 浏览:299
php用的软件 发布:2025-07-05 14:06:22 浏览:750
没有权限访问计算机 发布:2025-07-05 13:29:11 浏览:425
javaweb开发教程视频教程 发布:2025-07-05 13:24:41 浏览:686
康师傅控流脚本破解 发布:2025-07-05 13:17:27 浏览:233
java的开发流程 发布:2025-07-05 12:45:11 浏览:678
怎么看内存卡配置 发布:2025-07-05 12:29:19 浏览:277
访问学者英文个人简历 发布:2025-07-05 12:29:17 浏览:828