日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Sybase函数大全

發(fā)布時間:2024/4/17 63 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Sybase函数大全 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

http://wang-z-p2007.iteye.com/blog/1199142

SYbase函數(shù)學習(一)

ASCII 返回表達式中第一個字符的ASCII代碼。

如:select ASCII(‘Bennet’) 結果:66

select ASCII(‘B’) 結果:66

avg 返回所有(不同)值的數(shù)字平均值 avg([all | distinct ] expression),其中all為缺省值,表示全部;distinct是在應用avg之前取消重復值。Distinct是可選。當應用于group by子句時,集合函數(shù)將為每個組(而非整個表)生成一個值。

eg :將titles表按出版商分組,并且只包括那些預付款總額超過25000且書籍平均價格高于15的出版商所形成的組。

select? id ,sum(advance) , avg(price) from titles

group by id

having sum(advance) > 25000 and avg(price) >15

having與where類似,可用來決定選擇哪個記錄。在使用group by對這些記錄分組后,having會決定應顯示的記錄。

char 返回整數(shù)的等值字符。他將單字節(jié)整數(shù)值轉換為字符值(char通常用作ASCII的倒數(shù)

charindex 返回表示表達式起始位置的整數(shù)。

返回表company的列address中‘start’的起始位置。

eg:select charindex(“start”,address) from company where company_id = 57

char_length? 返回表達式中字符的數(shù)量。對于可變長度的列和變量,它將返回字符的個數(shù)(包括尾部的空格);對于文字和固定長度的字符列和變量,就是聲明的長度。所以一般我們要求字符串的長度,最后不要用這個。

col_length 返回已定義的列的長度。如:返回表tablename 的title列的長度,select col_length(‘tablename’,’title’)

注意:對text和image,numeric列比較特殊。

col_name 返回已指定ID和列ID的列的名稱,通俗點就是得到列名。

SYbase函數(shù)學習(二)

1.compare 直接比較兩個字符串,如果不一樣,則返回-1

2.convert 數(shù)據(jù)類型轉換函數(shù),如:convert(varchar(20),title)

3.count 返回非空值的數(shù)量或選定的行數(shù)。count([all|distinct] expression)

其中distinct是在應用count前取消重復值。

eg:查找作者居住的不同城市的數(shù)量:

select count(distinct city) from authors

eg:列出titles表中的類型,但取消只包含一本書或不包含任何書的類型:

select type? from titles group by type having count(*)>1

count(*)是返回行數(shù),用的最多。

4.current_date() 返回當前日期(不包括小時)。

eg: select current_date()

eg: 用datename標識當前日期

select datename(month,current_date())

結果:August

注意:結果不是8

eg:用datepart標識當前日期

select datepart(month,current_date())

結果:8

5.current_time() 返回當前時間

eg: select current_time()

eg: 返回當前時間的分鐘

select datename(minute,current_time())

6.curunreservedpas 返回指定磁盤區(qū)段中的可用頁數(shù)

Curunreservedpgs(dbid,istart,unreservedpgs)

dbid是數(shù)據(jù)庫的ID,它們存儲在sysdatabases的dbid字段。

Istart是要返回的頁所在磁盤區(qū)段中的一頁。

Unreservedpgs是在dbtable當前對于所請求的數(shù)據(jù)庫不可用時返回的缺省值。

eg: 返回數(shù)據(jù)庫名稱、設備名和每個設備區(qū)段中的未保留頁數(shù)。

select db_name(dbid),d.name ,curunreservedpgs(dbid,1,unreservedpgs)

from sysusages u ,sysdevices d where d.low <=u.size+vstart

and d.high>=u.size+vstart - 1

and d.status &2 = 2

eg:顯示從sysusages.istart開始的dbid段上的可用頁數(shù);

select curunreservedpgs(dbid, sysusages.istart,0)

實例化:select curunreservedpgs(6,1,0)

SYbase函數(shù)學習(三)

1.datalength 返回指定列或字符串的實際長度(以字節(jié)表示)

select datalength('a11中國')? 結果為7

select datalength('a11 ')? 結果為3

注意:結果是以字節(jié)表示

2.dateadd 返回向指定日期添加給定數(shù)量的年、季度、小時或其它分量后所得的日期分量后所得的日期。

Dateadd(date_part,integer, date expression)

如:titles表中所有書的出版日期推遲21

Select? newpubdate = dateadd(day,21,pubdate) from titles

向日期前添加一天

Select dateadd(dd,1,”apr 12,9999”)

向時間添加5分鐘

Select dateadd(mi,5,convert(time,”14:20:00”))

Select dateadd(hh,23,”4/1/1979”)

3.datediff 返回兩個日期之間的差值。

這個日期的差值可能是小時,天,年等。

4.datename 以字符串的形式返回指定datetime的指定部分。

Select datename(month,getdate()) 結果November

5.datapart 以整數(shù)的形式返回指定date的指定部分。

Select datapart (month,getdate())? 結果 4

6.day 返回指定日期的datepart中表示天的整數(shù)

Select day(‘11/02/03’) 結果 2

7.db_id 返回數(shù)據(jù)庫的ID

Select db_id(‘pub’) 返回pub數(shù)據(jù)庫的id

Select db_id()? 當前數(shù)據(jù)庫的ID

SYbase函數(shù)學習(四)

1. db_name 返回指定數(shù)據(jù)庫的名稱

它和db_id正好相反

例如:select db_name()???? 當前數(shù)據(jù)庫的名稱

Select db_name(4)?? ID為4的數(shù)據(jù)庫的名稱

2.floor 返回小于或等于指定值的最大整數(shù)

例如:select floor(123.24)? 結果:123

Select floor(-123.24)?? 結果:-124

Select floor($123.45)? 結果:123.00

注意:對于數(shù)字和小數(shù)表達式,其結果的精度與該表達式的精度相同,標度為0

3. getdate 返回當前系統(tǒng)日期和時間

例如:select getdate() 結果:當前日期,包括日期和時間

Select datepart(month,getdate()) 結果:12

Select datename(month,getdate()) 結果:December

4.host_id 返回當前Adaptive Server客戶端機操作系統(tǒng)進程ID,

host_name 返回當前Adaptive Server客戶端機操作系統(tǒng)進程名稱

例如:select host_name(),host_id()

結果:ylzhang1365

Ylzhang是計算機名,1365Adaptive Server客戶端進程的進程ID

5.identity_burn_max 跟蹤給定表的identity burn最大值,此函數(shù)只返還只而不進行更新。

例如:select? identity_burn_max(‘tablename’)

注意:返回的是自增列的最大ID,如果這個表沒有自增列,則返回為null

6.index_col 返回指定表或視圖中帶索引的列的名稱。

7.index_clolrder 返回列的順序

8.isnull expression求值為null時,用expression中的值替代它。

例如:select isnull(name,’zhang’) from titles 結果:name列為null值的替換為zhang

9.is_sec_service_on 安全服務啟用時返回1;否則返回0

is_sec_service_on(sevurity_service_nm)

其中:sevurity_service_nm是安全服務的名稱。

查找安全服務的有效名稱,用select * from syssecmechs

例如:select is_sec_service_on(“unifiedlogin”)

10.left 返回字符串最左側指定數(shù)目的字符。

left(character_expression,integer_expression)

例如:select left(‘123456789’,5) 結果:12345

select left(‘123 456789’,5) 結果:123 4

返回名字的前5個字符,select? left(name,5) from user

11.len 返回指定字符串表達式(不包括尾隨空白)的字符數(shù)(而不是字節(jié)數(shù))

len(string_expression)

例如:select? len(‘中國’) 結果:2

注意: char_lengthcharlen之間的區(qū)別

12.lower? 返回指定表達式的等值小寫表達式(就是把大寫字符變成小寫)

例如:select? lower(‘12FEC張’)? 結果:12fec

13.ltrim 返回指定的表達式,其中刪去了前導空白。

例如:select ltrim(‘? aa’)?????? 結果:aa

select ltrim(‘a(chǎn)a? ’)+’cc’?? 結果:aa? cc

select ltrim(‘a(chǎn)? a’)?????? 結果: a? a

注意:只刪去了前導空白

14.max min 返回列中最大值和最小值

例如:select max(price) from computer

????????????? select min(price) from computer

15.month 返回一個整數(shù),該整數(shù)表示月份。

例如:select month(getdate()) 結果:12

同理: select day(getdate())?? 結果:15

?????? select year(getdate())?? 結果:2006

16.mut_excl_roles 返回有關兩個角色之間互斥性的信息。

mut_excl_roles是一個系統(tǒng)函數(shù)。如果系統(tǒng)安全員將role1定義為與role2互斥的角色,或直接有role2所包含的角色,則mut_excl_roles返回1,如果不是則返回0。

17.newid 根據(jù)提供的參數(shù)生成兩種不同格式的、人工可讀的全局唯一ID

Newid([optionflag])

例如:select newid()

select newid(0)

select newid(0x0)

select newid(1)

可以通過newid()來參數(shù)隨機器數(shù)

Select id? from? tablename order by newid()

這時你會發(fā)現(xiàn),每次執(zhí)行,排序都不一樣。

18. next_identity 檢查下一個insert可用的下一個標識值。(就是下一個自增的ID)

Next_identity(tablename)

例如:select next_identity(‘tbl_zone’)? 結果:返回tbl_zone表中下一個要自增的id

注意:如果這個表不是自增,則返回null

19.object_id 返回指定對象的對象ID,object_name是返回對象ID的對象名稱。

Obeject_di(object_name)

object_name是數(shù)據(jù)庫對象(表、視圖、過程、觸發(fā)器、缺省值或規(guī)則)的名稱。

例如:select object_id(‘TBL_ZONE’)? 結果:437573566

同樣 select object_name(437573566)?? 結果:TBL_ZONE

注意:對象ID存儲在sysobjects的ID列中。

<script type="text/javascript"></script>

1.pi 返回常量3.1415926535897936。

例如:select pi()

注意:一般計算圓的時候用。

2.power 返回求指定數(shù)字的給定次冪所得的值。

Power(value,power)

例如:select power(2,4)? 結果:16

???????? select power(3,0)? 結果:1

3.proc_role 返回關于是否已授予用戶指定角色的信息。(通俗點就是你登陸后看看你是否有某些角色,有則返回1,否則返回0)

例如:檢查用戶是否已被授予系統(tǒng)安全員角色:

Select proc_role(‘sso_role’)

檢查用戶是否已被授予系統(tǒng)安全員角色:

Select proc_role(‘oper_role’)

4.rand 返回0-1之間的隨機值,該值是使用指定的源值來生成的。

例如:select rand()

5.replicate 返回將指定表達式重復特定次數(shù)所形成的字符串。

Replicate(char_expr|uchar_expr,integer_expr)

例如:select replicate(‘a(chǎn)b’,3)? 結果:ababab

6.reverse 返回其字符逆轉排列的指定字符串。

Reverse(expression|uchar_expr)

例如:select? reverse(‘我的電腦’) 結果:腦電的我

7.right 返回表達式最右邊具有指定字符數(shù)的部分。

Right(expression,integer_expr)

例如:select right(‘a(chǎn)bcdefj’,3)? 結果:efj

8.role_contain 當role2包含role1是返回1

role_contain(‘role1’,’role2’)

9.role_id? 返回已指定名稱的角色的系統(tǒng)角色ID

role_name? 返回已指定系統(tǒng)角色ID的角色名稱

role_id(‘role_name’)

role_ name’(role_id)

例如:返還sa_role的系統(tǒng)角色ID

Select? role_id(‘sa_role’)? 結果:0

Select? role_name(0)? 結果:sa_role

10.round 返回指定數(shù)字舍入到給定的小數(shù)位后所得的值。

round(number,integer)

例如:select round(123.4545,2)? 結果:123.4500

???????? Select round(123.45,-2)?? 結果:100.00

???????? Select round(123.506,2)??? 結果:123.510

注意:如果integer為負數(shù)且超過number的有效數(shù),則為0

11.rtrim 返回刪去尾隨空白的指定表達式。

Select rtrim(char_expr|uchar_expr)

例如:select rtrim(‘ aa’)??? 結果: aa

select rtrim(‘? aa ’)? 結果:? aa

select rtrim(‘a(chǎn)? a? ’)????? 結果:a? a

注意:它只刪去末尾的空白,其他的不會刪去

12.show_role 顯示登陸的當前啟用的角色。

例如:select show_role()

13.show_sec_services 列出可供會話使用的安全服務。

例如:select show_sec_services()

注意:如果沒有,則為null

14.sign 返回指定值的符號:+1(正)、0或-1(負)

Sign(numeric)

例如:select sign(123)? 結果:1

???????? select sign(0)? 結果:0

???????? select sign(-123)? 結果:-1

15.sin返回指定角的正弦。

例如:select? sin(45)

16.space? 返回由指定數(shù)量的單字節(jié)空格所組成的字符串。

Space

例如:select “aa”+space(5)+”dd”? 結果:aa???? dd

17.square 返回表示為float的指定值的平方值。

Square(numeric)

例如:select square(price) from titles

Select square(5)? 結果:25.0

注意:次函數(shù)等同于power(muneric_expr,2),但是它返回float類型而不返回int類型。

18.sqrt 返回指定數(shù)字的平方根。

例如:select sqrt(100)? 結果:10

sybase函數(shù)學習(六)

1.str? 返回指定數(shù)字的等值字符。

Str(approx_numeic[,length[,decimal]]).

例如:select str(125.36 , 5,2) 結果為125.3

125.36是數(shù)字

5是位數(shù),小數(shù)點也算

2是小數(shù)點后面的位數(shù),默認為0

注意:位數(shù)和小數(shù)點后面的位數(shù)的規(guī)律,試試就明白了。

2.str_replace 將第一個字符串表達式中出現(xiàn)的第二個字符串表達式的所有實例替換為第三個表達式。

例如:select str_replace(‘a(chǎn)aabbbccc’,’bb’,’mm’)? 結果:aaammbccc

3.stuff 返回通過以下方法形成的字符串:從一個字符串中刪除指定數(shù)量的字符,然后將這些字符替換為另一個字符串。

例如:select stuff(‘a(chǎn)bcdefg’,2,3,’mm’)? 結果:ammefg

2 是開始刪除字符的位置

3是刪除字符數(shù)

mm是替代

如:select stuff(‘ssssss’,2,3,null)

select stuff(‘ssssss’,2,3,’’)

4.substring 截取字符串中的一部分.

Substring(expression,start,length)

例如: select substring(‘a(chǎn)bcdef’,1,3)? 結果:abc

5.sum 返回值的總和

Sum([all|distinct] expression)

注意: distinct在這里的用法

6.suser_id? 從syslogins表中返回服務器用戶的ID號

suser_name? 從syslogins表中返回服務器用戶的名稱

Suser_id([server_user_name])

例如:select suser_id()

或? select suser_id(‘lei’)

select suser_name()

或 select suser_name(4)

7.syb_quit 終止連接.

例如:終止在其中執(zhí)行該函數(shù)且返回錯誤消息的連接.

Select syb_quit()

8.tempdb_id 報告給定會話分配到的臨時數(shù)據(jù)庫.

9.upper 返回指定字符串的等值大寫字符串.

例如:select upper(‘a(chǎn)b’)? 結果: AB

10.used_pgs 返回表或索引所用的頁數(shù).

11.user 返回當前用戶的名稱.

例如:select? user? 結果:dbo

12.user_id 返回數(shù)據(jù)庫中指定用戶或當前用戶的ID號

user_name 返回數(shù)據(jù)庫中指定用戶或當前用戶的名稱.

例如:select user_id()

或select user_id(‘lei’)

或select user_name()

或select user_name(4)

13.valid_name? 如果指定字符串不是有效標識符,則返回0,否則返回非0數(shù)字

14.vaild_user 看是否是一個數(shù)據(jù)庫中的有效用戶或別名.

例如:select valid_user(4)?

15.year 返回年

例如:select year(‘12/20/2006’)? 結果:2006

sybase函數(shù)學習(七)

1.將兩個字符串并置,用+

例如:select? '神秘'+'狹'??? 結果:神秘狹

2.between……and? 查詢兩個值之間的數(shù)字.

例如:? ……where column1 between 5 and? 100

3.1+null?? 結果:null

4.expression is null等效expression=null

expression is not? null等效expression!=null

5.要讓一個字符串延續(xù)到屏幕的下一行,可用\

6.臨時表以#開頭.

例如:create table #zone(zone_id int)

7.如果是關鍵字,就不能用于表名或列名,必須用分隔標識符(加雙引號)才能插入.在創(chuàng)建或引用分隔標識符之前,必須執(zhí)行set quoted_identitfier on

例如: set quoted_identitfier on

Create table “time”(“id” int)

set quoted_identitfier off

8.database.ower.table_name.column_name(數(shù)據(jù)庫名稱.所有者名稱.表名稱.列名稱),

也可以database..table_name

9.確定標識符是否有效:select valid_name(“object_name”)

10.使用sp_rename重命名用戶對象.

11.like 匹配,not like 是不匹配

例如: ….where like “415%”

使用通配符

12.% 任何包含0或者多個字符的字符串

例如:查詢以568開頭的電話號碼

Select number from authors where number like ‘568%’

13._? 任何單個字符

例如:查詢以”zhang”結尾的六個字母的姓名

Select name from users where name like “_zhang”

14.[]? 指定范圍或集合內(nèi)的任何單個字符

例如:查詢以”zhang”結尾并以M和Z間的任意單個字符開頭的姓名

Select name from users where like “[M-Z]inger”

查詢”zhang”和”Zhang”的姓名

Select name from users where name like “[Zz]hang”

15.[^]??? 不在指定范圍或集合內(nèi)的任何單個字符

例如:返回以zhang開頭且后面一個字符不是y的姓名

Select name from users where name like “zhang[^y]%”

16.escape子句作為轉義字符.

例如:like ”6@%” escape”@”? 表示6%

sybase函數(shù)學習(八)

1.alter database? 增加分配給數(shù)據(jù)庫的控件量

alter database mydb on mydate =50???? --(在數(shù)據(jù)庫設備mydb 上加50m數(shù)據(jù)空間,)
????????????????????????????????? log on mylog=10????? --(在數(shù)據(jù)庫設備mylog上加10m日志空間,)

2.alter role? 定義角色之間的互斥關系;為角色添加,刪除和更改口令;指定口令有效期,最小口令長度以及知道角色允許的最大登陸嘗試失敗次數(shù).

例子1:將intern_role和specialist_role定義為互斥:

alter role specialist_role add exclusive membership intern_role

例子2:在成員資格級別和激活級別將角色定義為互斥

alter role specialist_role add exclusive membership intern_role

alter role intern_roleadd add exclusive activation surgeon_role

例子3:添加口令到現(xiàn)有的角色

alter role doctor_role add password “zhang”

例子4:從現(xiàn)有角色刪除口令

alter role doctor_role drop password

例子5:鎖定角色physician_role

alter role physician_role? lock

例子6:解鎖角色physician_role

alter role physician_role? unlock

例子7:將physician_role允許的最大登陸嘗試失敗次數(shù)改為5

alter role physician_role set max failed_logins 5

例子8:將現(xiàn)有角色physician_role的最短口令長度設置為5個字符

alter role physician_role set min password length 5

例子9:替換所有角色的最短口令長度

alter role “all overrides”? set min password length-1

例子10 刪除所有角色的最大登陸失敗次數(shù)的替換值

alter role? “all overrides”? set max password length-1

注意:一般為角色更改口令,請先刪除口令,在添加口令.

3.alter table 向表添加新列;刪除或修改現(xiàn)在的列;添加,更改或刪除約束;更改現(xiàn)有表的屬性;啟用或禁用表上的觸發(fā)器;

例子1:向表中添加一列

alter table tablename add? manager_name varchar(50) null

例子2:向表中添加identity列

alter table tablename add? user_id? numeric(19,0) identity

例子3 向表中添加主鍵約束.

alter table? autors add? constraint? au_identification primary key(au_id,au_lname,au_fname)

例子4 在authors表上創(chuàng)建索引,設置reservepagegap值為16,在索引中為每15個分配的頁留一個空白頁

alter table? authors

add constraint au_identification

primary key(au_id,au_lname,au_fname)

with reservepagegap=16

例子5 刪除au_identification約束

alter table tablename

drop constraint au_identification

例子6 刪除authors表中phone列的缺省約束.如果列允許為空值,則沒有指定值時會插入空值.如果列不允許空值,則不指定列的插入,操作將失敗

alter table? authors

replace? phone default null

例子7:為表創(chuàng)建4個新的頁鏈.將表分區(qū)后,現(xiàn)有的數(shù)據(jù)會保存在第一個分區(qū),但是新的行會插入到所有這5個分區(qū)中

alter table tablename? partition 5

例子8 并置表的所有頁鏈,然后將其重新分區(qū)為6個分區(qū)

alter table tablename? unpartition

alter table tablename? partition 6

例子9 將tablename表的鎖定方案更改為數(shù)據(jù)行鎖定

alter table tablename lock datarows

例子10 將非空列author_type 添加到缺省值為primary_author的authors表

alter table authors

add author_type varchar(20)

default “primary_author”? not null

例子11 從表中刪除列

alter table tablename

drop id,name

例子12 將表authors的city列修改為默認值為空值的varchar(30)

alter table authors

modify city varchar(30)? null

例子13 stores表中的name列修改為非空.

alter table stores

modify name not null

例子14 修改titles表的type列,并將titles表的鎖定方案從所有頁鎖定更改為數(shù)據(jù)行鎖定

alter? table titles

modify type varchar(10)

lock datarows

例子15 將titles表的notes列由varchar(50),將缺省值由空更改為非空,并知道exp_row_size值為40

alter table titles

modify notes varhcar(50)? not null

with? exp_row_size=40

例子16 添加,修改和刪除一列,然后在同一查詢中添加另一列.改變鎖定方案,并指定新列的exp_row_size值.

alter table titles

modify city varhcar(50)?? null

drop notes

add sec_advance money default 1000 not null

lock datarows

with? exp_row_size=40

sybase函數(shù)學習(九)

1.begin…..end? 包含一系列SQL語句,以使控制語言可以影響整個組的性能.

例如: if(select avg(number) frim? zone)<18

??????? Begin

????????????? …………..

????????????? ………….

????????????? ………..

??????? end

2.begin transaction? 標記用戶定義的事務的起點.

例如:為insert語句顯示的開始一個事務

Begin transaction

?????? Insert? into publishers(pub_id) values(“445”)

Commint transaction?? --關閉事務

注意:要取消所有或部分事務,請使用rollback命令.rollback命令必須出現(xiàn)在事務內(nèi);不能在提交事務后在回退事務.

3.break 導致從while循環(huán)中退出.

例如: while aa>12

?????? Begin

?????? …………

?????? If bb>5

????????????? Break

?????? Else

????????????? Continue

?? End

注意: Break是中斷while,而continue是中斷本次循環(huán).

4.case 可以用于任何可以使用值表達式的情況.

例子1:把表查詢結果中name為C的改為fff

SELECT id ,

case

when name='C'

then 'fff'

else name

end?

from? A

注意: end不能忘, else name如果不要,其他的name都為null了

5.close 使游標失效

例子: close cursor_name

6.coalesce 它的作用和isnull一樣

Coalesce(expression,expression1[,expression1]….)

例子: select id ,coalesce(name,yun,'dddd'),isnull(name,'yun') from A

說明:字段name為null,就用yun的字段代替,如果yun的字段也為null,用’ddd’代替

7.create database 創(chuàng)建數(shù)據(jù)庫

Create database mydb on mydate =50???? --(在數(shù)據(jù)庫設備mydb 上加50M數(shù)據(jù)空間,)
????????????????????????????????? log on mylog=10????? --(在數(shù)據(jù)庫設備mylog上加10M日志空間,)

8.create default 創(chuàng)建默認值,如果插入時沒有顯示地提供要插入列中的值,則指定一個值.

例子1;定義一個缺省值,綁定在列中

Create defulat? phonedflt as “unknown”

Sp_bindefault phonedflt , “authors.phone”

sybase函數(shù)學習(十)

1.create function 通過將SQL包裝加入到JAVA靜態(tài)方法中,創(chuàng)建用戶定義的函數(shù).可返回一由該方法定義的值.

2.create index 創(chuàng)建表中一個或多個列的索引.

例子1.在authors表的au_id列上創(chuàng)建名為au_id_ind的索引:

Create index? au_id_ind on? authors(au_id)

例子2.在authors表的au_id列上創(chuàng)建名為au_id_ind的唯一聚族索引:

Create unique clustered? index? au_id_ind on? authors(au_id)

例子3 在authors表的au_id和title_id列上創(chuàng)建名為ind1的索引

Create index? ind1? on? authors? (au_id, title_id)

3.create plan? 創(chuàng)建抽象計劃

例子 為指定查詢創(chuàng)建抽象計劃.

Create? plan? “select? * from titles ” “(t_scan titles)”

4.create? procedure 創(chuàng)建存儲過程或可以帶一個或多個用戶提供的參數(shù)的擴展存儲過程.

例子

create? procedure? showed(@name? varchar(100))

as

select * from authors where name=@name

下面是執(zhí)行showid的可接受的語法形式”

Execute? showed? titles

或execute? showed? @name=”tiltes”

5.create? role 創(chuàng)建用戶定義角色.指定允許用于所創(chuàng)建的特定角色的口令有效期,最小口令長度和最大失敗登陸次數(shù).

例子1 創(chuàng)建名為doctor_role的角色

Create role doctor_role

例子2. 創(chuàng)建名為doctor_role且口令為haha的角色

Create role doctor_role with passwd “haha”

例子3 設置intern_role的有效期

Create role intern_role , with passwd “haha”, passwd ecpiration 6

例子4 設置intern_role的最大失敗登陸次數(shù)

Create role intern_role , with passwd “haha”, max failed_logins 20

例子5 設置intern_role的最短口令長度

Create role intern_role , with passwd “haha”, min passwd length 0

6.create rule 為特定列或?qū)儆谟脩舳x數(shù)據(jù)的任意列指定可接受值的域并創(chuàng)建訪問規(guī)則.

例子1 創(chuàng)建一個名為limit的規(guī)則,該規(guī)則限制advance的值小于1000

Create? rule? linit

As @advance <1000

例子2 創(chuàng)建名為pubid_rule的規(guī)則,該規(guī)則限制pub_id的值為13,14或15

Create rule? pubid_rule

As @pub_id in (‘13’,’14’,’15’)

sybase函數(shù)學習(十一)

1.disk? mirror 創(chuàng)建在主設備發(fā)生故障時立即接替運行得軟件鏡像。

2.disk? refit?? 通過sysdevices中的信息重建master數(shù)據(jù)庫的sysusages和sysdatabases系統(tǒng)表

3.disk????? reinit? 重建master數(shù)據(jù)庫的sysdevices系統(tǒng)表。將disk reinit作為過程的一部分使用,以便恢復master數(shù)據(jù)庫。

4.disk remirror?????? 在磁盤鏡像因鏡像設備故障而停止或者被disk? unmirror命令臨時禁用后重新啟動它。

5.disk? resize?? 動態(tài)添加Adaptive Server使用的設備的大小。

例子:disk resize

????????????? Name = “test_dev”

????????????? Size = “10M”

6.disk? unmirror 掛起用disk mirror命令啟動的磁盤鏡像,以允許硬件維護或硬件設備的更改。

7.drop database? 刪除一個或多個數(shù)據(jù)庫。

8.drop default? 刪除用戶定義的缺省值。

例子 :刪除數(shù)據(jù)庫中用戶定義的缺省datedefault

Drop default? datedefault

9.drop function 刪除SQL函數(shù)

10.drop index 從當前數(shù)據(jù)庫的表中刪除索引。

例子:從authors表中刪除au_id_ind

Drop index? authors. au_id_ind

11.drop procedure 刪除存儲過程。

例子:刪除存儲過程shoind

Drop procedure shoind

12.drop role刪除用戶定義角色

13.drop rule 刪除用戶定義的規(guī)則。

14.drop table 從數(shù)據(jù)庫中刪除表定義及其所有的數(shù)據(jù)、索引、觸發(fā)器和權限。

15.drop trigger 刪除觸發(fā)器。

16.drop view 從當前數(shù)據(jù)庫中刪除一個或多個視圖。

<script type="text/javascript"></script> sybase函數(shù)學習(五)

?

總結

以上是生活随笔為你收集整理的Sybase函数大全的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。