SYBASE資料庫總結

2021-08-30 23:46:54 字數 2194 閱讀 7222

sybase中插入資料的方式有:

1.insert into #b_header_temp(cust_record_id)

select min(id)

from #c_record_temp

group by out_order_no

2.select rowid=identity(18),t.*

into #b_cust_temp

from #b_header_temp h,#c_record_temp t

where t.out_order_no=h.out_order_no

sybase中給變數賦值的方式有:

1.declare

@curr_rowid int

set @curr_rowid=@curr_rowid+1

2.select @curr_rowid = null

select @outchar='four'

select @first=123

sybase中if語句的使用:

if(exists(select * from b_header where borr_no=444))

begin

select top 1 * from b_header

endelse

begin

select top 2 * from b_header

endsybase中顯示定義的變數值的方式:

1.一次只給乙個變數賦值

declare

@tt varchar(30),

@i_count int

select @tt='ddddddddd'

select @i_count=10008

print @tt

--print @i_count --說明:sybase中只允許通過print列印varchar或char型別的變數值,不允許列印int型的變數值

2.一次性給多個變數賦值

declare

--定義多個變數

@i varchar,@t varchar,@y int

--分別同時給多個變數賦值

select @i='ddd',@t='fjfjf',@y=3

--給@y變數重新賦值

set @y=1

print @i,@t

sybase中null與null的比較

/**執行以下**將列印出"null = null"

**/if(isnull(null,null) = null )

begin

print 'null = null'--在sybase中null 與null是相等的

endelse

begin

print 'null <> null'

end

建立id自增表

drop table s_test

gocreate table s_test(

idn int identity,

pt_no varchar(48) null

)with identity_gap=1--with identity_gap = 1 是增幅,等於1表示自增1

goinsert into s_test(part_no)

select test_col

from c_h_20110724

sp_whon  a--檢視當前使用者在資料庫上正在操作的資料庫物件和執行狀態

sp_who --檢視當前資料庫的所有登陸使用者資訊

sp_who itleader --檢視當前資料庫指定登陸使用者(itleader)資訊

判斷資料庫物件是否存在:

if object_id('tempdb..ad185119') is not null

drop table tempdb..ad185119go或

if exists(select 1

from sysobjects

where id=object_id('dbo.load_batch')

and type='p')

drop procedure dbo.load_batch

go

Sybase資料庫使用總結

1 對xml型別的字段作為查詢條件 xmlvalue欄位中儲存的內容 1.0 com.ciat.mobile.hkmobileegov zakzak 查詢的儲存過程 alter procedure dba xml select condition begin select xmlid,xmlvalu...

sybase資料庫恢復

一 對tempdb的恢復 測試 在資料庫執行狀態下,在系統中rm刪除了擴充套件的tempdb裝置tempdbdev.dat,initializing virtual device 6,syb data tempdbdev.dat error 822,severity 20,state 2 恢復 停止...

Sybase資料庫簡介

sybase資料庫簡介 八卦一下 剛開始sybase的資料庫一般叫作sybase sql server,你沒仔細瞧還以為是微軟的sql server呢.實際上兩者是有很大關聯的.sql server最初是由microsoft sybase與ashton tate三有公司共同研發的.到最後大家合不來就...