環境:
servername : test1
databasename : test1
tablename : table11
server name : test2
database name : test2
table name : table21
dsedit 加入同步伺服器設定
1> exec sp_addserver test2, asenterprise, test2 ######新增遠端伺服器資訊
2> go
adding server 'test2', physical name 'test2'
server added.
(return status = 0)
1> exec sp_addexternlogin test2, sa, sa , sybase ######新增遠端登陸資訊
2> go
user 'sa' will be known as 'sa' in remote server 'test2
(return status = 0)
1> use test11
2> go
1> create proxy_table table21 at "test2.test21.dbo.table21" ######建立**表
2> go
1> select * from table21 ######可訪問遠端伺服器表
2> go
id name
----------- ----------
2 alvin2
(1 row affected)
1> create trigger tr_table11 ######建立觸發器同步資料
2> on table11
3> for insert,update,delete
4> as
5> if not exists(select * from deleted) and exists(select * from inserted)
6> begin
7> insert into table21 select * from inserted
8> end
9> else if exists(select * from deleted) and not exists(select * from inserted)
10> begin
11> delete from table21 where id in (select id from deleted)
12> end
13> else if exists(select * from deleted) and exists(select * from inserted)
14> begin
15> delete from table21 where id in (select id from deleted)
16> insert into table21 select * from inserted
17> end
18> go
1> insert into table11 values(1,"alvin")
2> go
(1 row affected)
1> select * from table21
2> go
id name
----------- ----------
1 alvin
(1 row affected)
1> insert into table11 values(2,"alvi")
2> go
(1 row affected)
1> insert into table11 values(3,"alv")
2> go
(1 row affected)
1> commit
2> go
1> select * from table21 ######插入資料同步成功
2> go
id name
----------- ----------
1 alvin
2 alvi
3 alv
(3 rows affected)
1> delete from table11 where id=1
2> go
(1 row affected)
1> select * from table21 ######刪除資料同步成功
2> go
id name
----------- ----------
2 alvi
3 alv
(2 rows affected)
1> commit
2> go
1> update table11 set name="ultra" where id=2
2> go
(1 row affected)
1> select * from table21
2> go
id name
----------- ----------
3 alv
2 ultra
(2 rows affected)
1> update table11 set name="ultra" where id=3
2> go
(1 row affected)
1> commit
2> go
1> select * from table21 ######更新資料同步成功
2> go
id name
----------- ----------
2 ultra
3 ultra
(2 rows affected)
1> delete from table11 where id=2
2> go
(1 row affected)
1> select * from table21
2> go
id name
----------- ----------
3 ultra
(1 row affected)
1> delete from table11 where id=3
2> go
(1 row affected)
1> commit
2> go
1> select * from table21
2> go
id name
----------- ----------
(0 rows affected)
缺點:當備庫出現問題的時候 ,會影響主庫。
sybase 表分割槽
最近想對乙個表進行分割槽,在sybase版轉了半天,沒找著詳細介紹表分割槽有關的帖子.終於找著一篇比較詳細的,故貼之 sybase ase表分割槽的使用 表分割槽是目前各主流資料庫都提供的常用技術,各大資料庫基於不同的體系結構提供了各具特色的實現,如果能合理使用這種技術,將為系統效能的提公升帶來意想...
Sybase資料庫表備份
1.insert into select語句 語句形式為 insert into table2 field1,field2,select value1,value2,from table1 要求目標表table2必須存在,由於目標表 table2 已經存在,所以我們除了插入源表 table1 的字段...
Sybase常用表操作
sybase常用表操作 表建立 建立一名為 rds custom ftp 的表,並設定id gap為1000.create table rds custom ftp sid numeric 12,0 identity,sub no int not null,ftp url varchar 50 no...