我的团队正在研究不同数据库平台提供的地理空间功能.
是否所有实现数据库都是特定的,或者是否存在ANSI SQL标准或类似类型的标准,这些标准将在未来提供或将提供?
我问,因为我希望实现的代码尽可能与数据库无关(我们的项目被编写为ANSI SQL标准).
将来是否有任何已知的此功能标准化计划?
ANSI-92 SQL要求将NULL评估与"falsy"进行比较,例如:
SELECT * FROM table WHERE field = NULL
SELECT * FROM table WHERE field != NULL
Run Code Online (Sandbox Code Playgroud)
两者都不会返回任何行,因为NULL无法像那样进行比较.相反,谓语IS NULL和IS NOT NULL必须改用:
SELECT * FROM table WHERE field IS NULL
SELECT * FROM table WHERE field IS NOT NULL
Run Code Online (Sandbox Code Playgroud)
研究表明,Oracle 1,PostgreSQL,MySQL和SQLite都支持ANSI语法.添加到该列表DB2和Firebird.
除了ANSI_NULLS关闭SQL Server之外,还有哪些其他RDBMS支持非ANSI语法?
1整个空字符串= NULL尽管很糟糕.
我的意思并不是"基本SQL",而是强烈的规范和规范与伟大数据库(如SQL Server,Oracle等)之间的实现之间的差异.
我正在尝试将一些Oracle SQL查询转换为(理论上)任何SQL数据库.一些查询本质上是分层的,并且使用CONNECT BY编写.
是否有Oracle的START WITH ... CONNECT BY语法的标准SQL替代方法?或者是否有一些我应该遵循的推荐过程来转换分层查询?
我需要一种方法来确定SQL中两个日期之间的天数.
答案必须是ANSI SQL.
可以在SQL中完成任何这些查询吗?
SELECT dates FROM system
WHERE dates > 'January 5, 2010' AND dates < 'January 30, 2010'
SELECT number FROM system
WHERE number > 10 AND number < 20
Run Code Online (Sandbox Code Playgroud)
我想创建一个generate_series,这就是我要问的原因.
我有一个简单的查询,我想知道它是否可以更优雅地编码.最终解决方案必须符合ansi标准.
我需要根据日期和版本从表中获取最新值.样本会更清楚地解释:
declare @t table (id int, due_date smalldatetime, version int, value nvarchar(10))
insert into @t select 3, '1/1/2010', 1, 'value 1'
insert into @t select 3, '1/1/2010', 2, 'value 2'
insert into @t select 3, '3/1/2010', 1, 'value 3'
insert into @t select 3, '3/1/2010', 2, 'value 4'
insert into @t select 3, '3/1/2010', 3, 'value 5'
insert into @t select 3, '3/1/2010', 4, 'value 6'
insert into @t select 3, '4/1/2010', 1, 'value 7'
insert into @t select …Run Code Online (Sandbox Code Playgroud) 我已经看了很多类似的问题,但还没有发现/找到下面问题的正确解决方案.
给出以下三个表:
account
profile_id number (nullable)
bill_acct varchar
status varchar (nullable)
remarks varchar (nullable)
stage
ecpd_profile_id number (nullable)
bill_account varchar (nullable)
account_class varchar (nullable)
profile
ecpd_profile_id number
reg_prof_id number
Run Code Online (Sandbox Code Playgroud)
我需要创建一个连接来选择以下内容:
account.bill_act, account.status, account.remarks, stage.account_class
Run Code Online (Sandbox Code Playgroud)
哪里
profile.ecpd_profile_id = (given number)
Run Code Online (Sandbox Code Playgroud)
account.profile_id并且profile.reg_prof_id是等价的
stage.ecpd_profile_id并且profile.ecpd_profile_id是等价的
stage.bill_acct并且account.bill_acct是等价的
我试过以下......
select
account.bill_acct,
account.status,
account.remarks,
stage.account_class
from
registration_account account
join registration_profile profile
on account.profile_id = profile.reg_prof_id
join acct_stg stage
on stage.ecpd_profile_id = profile.ecpd_profile_id
and stage.bill_acct = account.bill_acct
where
profile.ecpd_profile_id …Run Code Online (Sandbox Code Playgroud) 我是 SQL 新手,一直在寻找一种在 ANSI SQL 中设置变量的方法。我有这个:
select * from table1
where first_date > '2014-01-01'
and where second_date = '2014-01-01'
and where third_date < '2014-01-01'
Run Code Online (Sandbox Code Playgroud)
但我希望有这样的事情:
set x = '2010-12-31'
select * from table1
where first_date > x
and where second_date = x
and where third_date < x
Run Code Online (Sandbox Code Playgroud)
我读过有关存储过程的内容,但对于看似简单的事情来说,这似乎有点矫枉过正。我正在 Netezza 上运行,但我想要一个也可以在其他数据库上运行的通用解决方案。
有没有办法可以强制我的 sql server 数据库只使用符合 SQL 的代码?
通过这种方式,SQL 代码可以轻松传输到其他数据库系统,如 Oracle、IBM 和其他符合 ANSI 标准的系统。
或者其他可行的方法来获得相同的结果?
ansi-sql ×10
sql ×10
sql-server ×3
oracle ×2
date ×1
geospatial ×1
join ×1
netezza ×1
null ×1
t-sql ×1