sybase和sqlserver 在sql语句上有什么区别

libra_xxy 2011-04-29 02:28:12
sybase和sqlserver 在sql语句上有什么区别???????????
还有就是谁有dbvis可视化工具的操作?????????????

谢了
...全文
196 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
axie534 2011-05-06
  • 打赏
  • 举报
回复

--判断titles是否存在 存在则删除
if exists (select * from sysobjects where name = 'titles')
drop table titles
-- 创建表
create table titles(
title_id int not null,
title varchar(80) not null,
type char(12) default 'UNDECIDED' not null ,
pub_id char(4) null,
price money null,
advance money null,
royalty int null,
ytd_sales int null,
notes varchar(200) null,
pubdate datetime default GETDATE() not null
)
-- 设置主键
alter table titles add constraint pk_titles primary key(title_id)
-- 添加数据
insert into titles(title_id,title,type,pub_id,price,advance,royalty,ytd_sales,notes,pubdate)
values(1,'数据库系统原理','DATABASE','0001',32,20,1,100,'',getdate())


if exists (select * from sysobjects where name = 'publishers')
drop table publishers

create table publishers(
pub_id char(4) not null,
pub_name varchar(40) null,
city varchar(20) null,
state char(2) null,
country varchar(30) default 'USA' null
)
alter table publishers add constraint pk_publishers primary key(pub_id)
-- 添加外键
alter table titles add constraint fk_pub_id foreign key (pub_id) references publishers(pub_id)
insert into publishers(pub_id,pub_name,city,state,country)
values('0001','机械出版社','北京','1','CHINA')
-- 修改语句语句
UPDATE titles SET price = price * 2 WHERE pub_id IN (SELECT pub_id FROM publishers WHERE pub_name = 'New Moon Books')


-- 删除语句
DELETE publishers WHERE pub_id IN(SELECT pub_id FROM titles WHERE type = 'business')
-- EXISTS 关键字
SELECT * FROM publishers WHERE EXISTS(SELECT * FROM titles WHERE pub_id = publishers.pub_id AND type = 'business')

-- 使用比较运算符的子查询
子查询可由一个比较运算符(=、< >、>、>=、<、!>、!<或<=)引入。
要使用比较运算符引入的子查询,必须对数据和问题的本质非常熟悉,以了解该子查询返回一个值还是值列表。
例如,如下查询将显示价格不是最低的书目。
SELECT DISTINCT title FROM titles WHERE price >
(SELECT MIN(price) FROM titles)

-- 使用别名的相关子查询
SELECT DISTINCT t1.type
FROM titles t1
WHERE t1.type IN
(SELECT t2.type
FROM titles t2
WHERE t1.pub_id <> t2.pub_id)
-- having子句中的相关子查询
SELECT t1.type
FROM titles t1
GROUP BY t1.type
HAVING MAX(t1.advance) >=ALL
(SELECT 2 * AVG(t2.advance)
FROM titles t2
WHERE t1.type = t2.type)

-- top关键字
SELECT top 3 * FROM titles –- 这样是对的
SELECT top 3 * FROM titles where pub_id in (select top 1 pub_id from publishers where pub_id='0001' )—在 in子句中不支持top关键字
-- set rowcount关键字
set rowcount 4 select title_id from titles –查询前四条的记录
-- inner join关键字
select * from titles join publishers on titles.pub_id =publishers.pub_id
select * from titles a ,publishers b where a.pub_id=b.pub_id



njwup 2011-05-01
  • 打赏
  • 举报
回复
sybase和sqlserver 在sql语句语法上没有多大区别,对函数支持有较多不同,大部分还是可以通用的。
ACMAIN_CHM 2011-04-29
  • 打赏
  • 举报
回复
有差别,但差别有多大则看个人理解了。

总体来说很多函数上会有所不同,但对标准的ANSI SQL语句都是支持的。

建议参考一下数据库自带的手册。
iihero 2011-04-29
  • 打赏
  • 举报
回复
Sybase的语法跟SQL Server2000的比较接近。往后发展,差别越来越大。
dbvis的操作,你下一个这个工具就知道了。
WWWWA 2011-04-29
  • 打赏
  • 举报
回复
语法差异比较大,具体是什么 问题?
可以搜索SYBASE、SQL2005的SQL语法看看

2,598

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧