Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
096f44e1
Unverified
提交
096f44e1
authored
5月 22, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
5月 22, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1156 from katzyn/ddl
Add support for SQL:2003 WITH [NO] DATA to CREATE TABLE AS
上级
a778d6ee
f249c20b
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
58 行增加
和
2 行删除
+58
-2
help.csv
h2/src/docsrc/help/help.csv
+2
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+4
-0
CreateTable.java
h2/src/main/org/h2/command/ddl/CreateTable.java
+6
-1
createTable.sql
h2/src/test/org/h2/test/scripts/ddl/createTable.sql
+46
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
096f44e1
...
@@ -708,7 +708,7 @@ TABLE [ IF NOT EXISTS ] name
...
@@ -708,7 +708,7 @@ TABLE [ IF NOT EXISTS ] name
[ ENGINE tableEngineName ]
[ ENGINE tableEngineName ]
[ WITH tableEngineParamName [,...] ]
[ WITH tableEngineParamName [,...] ]
[ NOT PERSISTENT ] [ TRANSACTIONAL ]
[ NOT PERSISTENT ] [ TRANSACTIONAL ]
[ AS select ]","
[ AS select
[ WITH [ NO ] DATA ]
]","
Creates a new table.
Creates a new table.
Cached tables (the default for regular tables) are persistent,
Cached tables (the default for regular tables) are persistent,
...
@@ -736,6 +736,7 @@ rows are lost when the database is closed.
...
@@ -736,6 +736,7 @@ rows are lost when the database is closed.
The column definition is optional if a query is specified.
The column definition is optional if a query is specified.
In that case the column list of the query is used.
In that case the column list of the query is used.
If the query is specified its results are inserted into created table unless WITH NO DATA is specified.
This command commits an open transaction, except when using
This command commits an open transaction, except when using
TRANSACTIONAL (only supported for temporary tables).
TRANSACTIONAL (only supported for temporary tables).
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
096f44e1
...
@@ -6679,6 +6679,10 @@ public class Parser {
...
@@ -6679,6 +6679,10 @@ public class Parser {
command
.
setSortedInsertMode
(
true
);
command
.
setSortedInsertMode
(
true
);
}
}
command
.
setQuery
(
parseSelect
());
command
.
setQuery
(
parseSelect
());
if
(
readIf
(
"WITH"
))
{
command
.
setWithNoData
(
readIf
(
"NO"
));
read
(
"DATA"
);
}
}
}
// for MySQL compatibility
// for MySQL compatibility
if
(
readIf
(
"ROW_FORMAT"
))
{
if
(
readIf
(
"ROW_FORMAT"
))
{
...
...
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
096f44e1
...
@@ -38,6 +38,7 @@ public class CreateTable extends CommandWithColumns {
...
@@ -38,6 +38,7 @@ public class CreateTable extends CommandWithColumns {
private
Query
asQuery
;
private
Query
asQuery
;
private
String
comment
;
private
String
comment
;
private
boolean
sortedInsertMode
;
private
boolean
sortedInsertMode
;
private
boolean
withNoData
;
public
CreateTable
(
Session
session
,
Schema
schema
)
{
public
CreateTable
(
Session
session
,
Schema
schema
)
{
super
(
session
,
schema
);
super
(
session
,
schema
);
...
@@ -120,7 +121,7 @@ public class CreateTable extends CommandWithColumns {
...
@@ -120,7 +121,7 @@ public class CreateTable extends CommandWithColumns {
table
.
addSequence
(
sequence
);
table
.
addSequence
(
sequence
);
}
}
createConstraints
();
createConstraints
();
if
(
asQuery
!=
null
)
{
if
(
asQuery
!=
null
&&
!
withNoData
)
{
boolean
old
=
session
.
isUndoLogEnabled
();
boolean
old
=
session
.
isUndoLogEnabled
();
try
{
try
{
session
.
setUndoLogEnabled
(
false
);
session
.
setUndoLogEnabled
(
false
);
...
@@ -245,6 +246,10 @@ public class CreateTable extends CommandWithColumns {
...
@@ -245,6 +246,10 @@ public class CreateTable extends CommandWithColumns {
this
.
sortedInsertMode
=
sortedInsertMode
;
this
.
sortedInsertMode
=
sortedInsertMode
;
}
}
public
void
setWithNoData
(
boolean
withNoData
)
{
this
.
withNoData
=
withNoData
;
}
public
void
setTableEngine
(
String
tableEngine
)
{
public
void
setTableEngine
(
String
tableEngine
)
{
data
.
tableEngine
=
tableEngine
;
data
.
tableEngine
=
tableEngine
;
}
}
...
...
h2/src/test/org/h2/test/scripts/ddl/createTable.sql
浏览文件 @
096f44e1
...
@@ -14,3 +14,49 @@ SELECT CONSTRAINT_NAME, CONSTRAINT_TYPE FROM INFORMATION_SCHEMA.TABLE_CONSTRAINT
...
@@ -14,3 +14,49 @@ SELECT CONSTRAINT_NAME, CONSTRAINT_TYPE FROM INFORMATION_SCHEMA.TABLE_CONSTRAINT
DROP
TABLE
TEST
;
DROP
TABLE
TEST
;
>
ok
>
ok
CREATE
TABLE
T1
(
ID
INT
PRIMARY
KEY
,
COL2
INT
);
>
ok
INSERT
INTO
T1
VALUES
(
1
,
2
),
(
11
,
22
);
>
update
count
:
2
CREATE
TABLE
T2
AS
SELECT
*
FROM
T1
;
>
ok
SELECT
*
FROM
T2
ORDER
BY
ID
;
>
ID
COL2
>
-- ----
>
1
2
>
11
22
>
rows
(
ordered
):
2
DROP
TABLE
T2
;
>
ok
CREATE
TABLE
T2
AS
SELECT
*
FROM
T1
WITH
DATA
;
>
ok
SELECT
*
FROM
T2
ORDER
BY
ID
;
>
ID
COL2
>
-- ----
>
1
2
>
11
22
>
rows
(
ordered
):
2
DROP
TABLE
T2
;
>
ok
CREATE
TABLE
T2
AS
SELECT
*
FROM
T1
WITH
NO
DATA
;
>
ok
SELECT
*
FROM
T2
ORDER
BY
ID
;
>
ID
COL2
>
-- ----
>
rows
(
ordered
):
0
DROP
TABLE
T2
;
>
ok
DROP
TABLE
T1
;
>
ok
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论