由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Does this kind of Query Make Sense?
相关主题
有什么比较好的学习sql的书或视频吗?how to query in the universal hash table?
被一个面试题卡的泪流满面 SQLSQL server optimal query design (转载)
sql 优化一问请教一个数据结构题
SQL find distinct values in large table (转载)请教个SQL的问题
一个hibernate insert db的问题Google电面
G家面题问个SQL query
SQL combine two columns from two different tables no shared columnswhat kinds of people got Google Offer
请帮忙回答一个SQL问题BST insertion
相关话题的讨论汇总
话题: query话题: sense话题: does话题: make话题: kind
进入JobHunting版参与讨论
1 (共1页)
c*********y
发帖数: 316
1
Oracle:
INSERT INTO (SELECT department_id, department_name, location_id
FROM departments WHERE location_id < 2000 WITH CHECK OPTION)
VALUES (9999, 'Entertainment', 1500);
why have select statement for insert columns? and also that where clause
does not make a lot of sense to me...
can someone one tell me what it means and what is the purpose for this kind
of query?
Thanks!
l*********8
发帖数: 4642
2
INSERT INTO后面少了table name.
otherwise it should be valid.

kind

【在 c*********y 的大作中提到】
: Oracle:
: INSERT INTO (SELECT department_id, department_name, location_id
: FROM departments WHERE location_id < 2000 WITH CHECK OPTION)
: VALUES (9999, 'Entertainment', 1500);
: why have select statement for insert columns? and also that where clause
: does not make a lot of sense to me...
: can someone one tell me what it means and what is the purpose for this kind
: of query?
: Thanks!

c*********y
发帖数: 316
3
no. it's correct.
think about it again please.

【在 l*********8 的大作中提到】
: INSERT INTO后面少了table name.
: otherwise it should be valid.
:
: kind

w**p
发帖数: 4080
4
终于看明白了。这里最重要的是那个with check option
任何insertion,只要location_id 大于等于2000,都会造成错误。也就是说不接受任
何>=2000的插入。这也是为什么有where的原因,with check option是和where在一起
的。
至于为什么有select那就简单了,只插值到选取的几个column,其余column将会是null。
不知道是否回答了你的问题。
c*********y
发帖数: 316
5
yeah.
but what is the practical purpose for this kind of query?

null。

【在 w**p 的大作中提到】
: 终于看明白了。这里最重要的是那个with check option
: 任何insertion,只要location_id 大于等于2000,都会造成错误。也就是说不接受任
: 何>=2000的插入。这也是为什么有where的原因,with check option是和where在一起
: 的。
: 至于为什么有select那就简单了,只插值到选取的几个column,其余column将会是null。
: 不知道是否回答了你的问题。

w**p
发帖数: 4080
6
with check option跟database的view有关
主要是保证一个数据库里的不同部分的数据的独立性和完整性。
有了with check option,只有这个where从句指向的那一部分数据可以被插入和更新,
而不会因为错误的操作把其他部分的数据给影响了。

【在 c*********y 的大作中提到】
: yeah.
: but what is the practical purpose for this kind of query?
:
: null。

1 (共1页)
进入JobHunting版参与讨论
相关主题
BST insertion一个hibernate insert db的问题
请教SQL问题G家面题
求教一个SQL的问题SQL combine two columns from two different tables no shared columns
count unique values in file with 1 million rows (转载)请帮忙回答一个SQL问题
有什么比较好的学习sql的书或视频吗?how to query in the universal hash table?
被一个面试题卡的泪流满面 SQLSQL server optimal query design (转载)
sql 优化一问请教一个数据结构题
SQL find distinct values in large table (转载)请教个SQL的问题
相关话题的讨论汇总
话题: query话题: sense话题: does话题: make话题: kind