當前位置:首頁 » 編程語言 » 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-02-10 09:59:11 瀏覽:455
光遇安卓國服9月的季節什麼時候來 發布:2025-02-10 09:58:35 瀏覽:724
引腳要復用為adc怎麼配置 發布:2025-02-10 09:54:24 瀏覽:979
q4演算法 發布:2025-02-10 09:54:24 瀏覽:637
編譯原理設計文檔是什麼 發布:2025-02-10 09:41:58 瀏覽:283
sql分段統計 發布:2025-02-10 09:40:27 瀏覽:358
記賬app源碼 發布:2025-02-10 09:34:45 瀏覽:496
照片傳到g6的存儲卡 發布:2025-02-10 09:29:02 瀏覽:902
非加密公章 發布:2025-02-10 09:09:52 瀏覽:621
京東登錄密碼如何清除 發布:2025-02-10 09:07:41 瀏覽:690