Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b3581c5d
Unverified
提交
b3581c5d
authored
7月 19, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
7月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1314 from katzyn/ddl
Add ALTER VIEW RENAME command
上级
7e3ef0c6
b8846f8f
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
95 行增加
和
13 行删除
+95
-13
help.csv
h2/src/docsrc/help/help.csv
+10
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+20
-8
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+2
-2
alterTableRename.sql
h2/src/test/org/h2/test/scripts/ddl/alterTableRename.sql
+61
-0
help.sql
h2/src/test/org/h2/test/scripts/other/help.sql
+2
-2
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
b3581c5d
...
@@ -468,7 +468,7 @@ This command commits an open transaction in this connection.
...
@@ -468,7 +468,7 @@ This command commits an open transaction in this connection.
ALTER USER SA SET PASSWORD 'rioyxlgt'
ALTER USER SA SET PASSWORD 'rioyxlgt'
"
"
"Commands (DDL)","ALTER VIEW","
"Commands (DDL)","ALTER VIEW
RECOMPILE
","
ALTER VIEW [ IF EXISTS ] viewName RECOMPILE
ALTER VIEW [ IF EXISTS ] viewName RECOMPILE
","
","
Recompiles a view after the underlying tables have been changed or created.
Recompiles a view after the underlying tables have been changed or created.
...
@@ -478,6 +478,15 @@ This command commits an open transaction in this connection.
...
@@ -478,6 +478,15 @@ This command commits an open transaction in this connection.
ALTER VIEW ADDRESS_VIEW RECOMPILE
ALTER VIEW ADDRESS_VIEW RECOMPILE
"
"
"Commands (DDL)","ALTER VIEW RENAME","
ALTER VIEW [ IF EXISTS ] viewName RENAME TO newName
","
Renames a view.
This command commits an open transaction in this connection.
","
ALTER VIEW TEST RENAME TO MY_VIEW
"
"Commands (DDL)","ANALYZE","
"Commands (DDL)","ANALYZE","
ANALYZE [ TABLE tableName ] [ SAMPLE_SIZE rowCountInt ]
ANALYZE [ TABLE tableName ] [ SAMPLE_SIZE rowCountInt ]
","
","
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
b3581c5d
...
@@ -5767,20 +5767,32 @@ public class Parser {
...
@@ -5767,20 +5767,32 @@ public class Parser {
return
command
;
return
command
;
}
}
private
AlterView
parseAlterView
()
{
private
DefineCommand
parseAlterView
()
{
AlterView
command
=
new
AlterView
(
session
);
boolean
ifExists
=
readIfExists
(
false
);
boolean
ifExists
=
readIfExists
(
false
);
command
.
setIfExists
(
ifExists
);
String
viewName
=
readIdentifierWithSchema
();
String
viewName
=
readIdentifierWithSchema
();
Table
tableView
=
getSchema
().
findTableOrView
(
session
,
viewName
);
Schema
schema
=
getSchema
();
Table
tableView
=
schema
.
findTableOrView
(
session
,
viewName
);
if
(!(
tableView
instanceof
TableView
)
&&
!
ifExists
)
{
if
(!(
tableView
instanceof
TableView
)
&&
!
ifExists
)
{
throw
DbException
.
get
(
ErrorCode
.
VIEW_NOT_FOUND_1
,
viewName
);
throw
DbException
.
get
(
ErrorCode
.
VIEW_NOT_FOUND_1
,
viewName
);
}
}
if
(
readIf
(
"RENAME"
))
{
read
(
"TO"
);
String
newName
=
readIdentifierWithSchema
(
schema
.
getName
());
checkSchema
(
schema
);
AlterTableRename
command
=
new
AlterTableRename
(
session
,
getSchema
());
command
.
setOldTableName
(
viewName
);
command
.
setNewTableName
(
newName
);
command
.
setIfTableExists
(
ifExists
);
return
command
;
}
else
{
read
(
"RECOMPILE"
);
TableView
view
=
(
TableView
)
tableView
;
TableView
view
=
(
TableView
)
tableView
;
AlterView
command
=
new
AlterView
(
session
);
command
.
setIfExists
(
ifExists
);
command
.
setView
(
view
);
command
.
setView
(
view
);
read
(
"RECOMPILE"
);
return
command
;
return
command
;
}
}
}
private
Prepared
parseAlterSchema
()
{
private
Prepared
parseAlterSchema
()
{
boolean
ifExists
=
readIfExists
(
false
);
boolean
ifExists
=
readIfExists
(
false
);
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
b3581c5d
...
@@ -123,8 +123,8 @@ public class TestScript extends TestDb {
...
@@ -123,8 +123,8 @@ public class TestScript extends TestDb {
"uuid"
,
"varchar"
,
"varchar-ignorecase"
})
{
"uuid"
,
"varchar"
,
"varchar-ignorecase"
})
{
testScript
(
"datatypes/"
+
s
+
".sql"
);
testScript
(
"datatypes/"
+
s
+
".sql"
);
}
}
for
(
String
s
:
new
String
[]
{
"alterTableAdd"
,
"alterTableDropColumn"
,
for
(
String
s
:
new
String
[]
{
"alterTableAdd"
,
"alterTableDropColumn"
,
"alterTableRename"
,
"createAlias"
,
"createSynonym"
,
"create
View"
,
"createTable"
,
"createTrigger
"
,
"createAlias"
,
"createSynonym"
,
"create
Table"
,
"createTrigger"
,
"createView
"
,
"dropDomain"
,
"dropIndex"
,
"dropSchema"
,
"truncateTable"
})
{
"dropDomain"
,
"dropIndex"
,
"dropSchema"
,
"truncateTable"
})
{
testScript
(
"ddl/"
+
s
+
".sql"
);
testScript
(
"ddl/"
+
s
+
".sql"
);
}
}
...
...
h2/src/test/org/h2/test/scripts/ddl/alterTableRename.sql
0 → 100644
浏览文件 @
b3581c5d
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
-- Test for ALTER TABLE RENAME and ALTER VIEW RENAME
CREATE
TABLE
TABLE1A
(
ID
INT
);
>
ok
INSERT
INTO
TABLE1A
VALUES
(
1
);
>
update
count
:
1
-- ALTER TABLE RENAME
ALTER
TABLE
TABLE1A
RENAME
TO
TABLE1B
;
>
ok
SELECT
*
FROM
TABLE1B
;
>>
1
ALTER
TABLE
IF
EXISTS
TABLE1B
RENAME
TO
TABLE1C
;
>
ok
SELECT
*
FROM
TABLE1C
;
>>
1
ALTER
TABLE
BAD
RENAME
TO
SMTH
;
>
exception
TABLE_OR_VIEW_NOT_FOUND_1
ALTER
TABLE
IF
EXISTS
BAD
RENAME
TO
SMTH
;
>
ok
-- ALTER VIEW RENAME
CREATE
VIEW
VIEW1A
AS
SELECT
*
FROM
TABLE1C
;
>
ok
ALTER
VIEW
VIEW1A
RENAME
TO
VIEW1B
;
>
ok
SELECT
*
FROM
VIEW1B
;
>>
1
ALTER
TABLE
IF
EXISTS
VIEW1B
RENAME
TO
VIEW1C
;
>
ok
SELECT
*
FROM
VIEW1C
;
>>
1
ALTER
VIEW
BAD
RENAME
TO
SMTH
;
>
exception
VIEW_NOT_FOUND_1
ALTER
VIEW
IF
EXISTS
BAD
RENAME
TO
SMTH
;
>
ok
SELECT
*
FROM
VIEW1C
;
>>
1
DROP
TABLE
TABLE1C
CASCADE
;
>
ok
h2/src/test/org/h2/test/scripts/other/help.sql
浏览文件 @
b3581c5d
...
@@ -16,11 +16,11 @@ HELP ABCDE EF_GH;
...
@@ -16,11 +16,11 @@ HELP ABCDE EF_GH;
HELP
HELP
;
HELP
HELP
;
>
ID
SECTION
TOPIC
SYNTAX
TEXT
>
ID
SECTION
TOPIC
SYNTAX
TEXT
>
-- ---------------- ----- ----------------------- ----------------------------------------------------
>
-- ---------------- ----- ----------------------- ----------------------------------------------------
>
6
4
Commands
(
Other
)
HELP
HELP
[
anything
[...]
]
Displays
the
help
pages
of
SQL
commands
or
keywords
.
>
6
5
Commands
(
Other
)
HELP
HELP
[
anything
[...]
]
Displays
the
help
pages
of
SQL
commands
or
keywords
.
>
rows
:
1
>
rows
:
1
HELP
he
lp
;
HELP
he
lp
;
>
ID
SECTION
TOPIC
SYNTAX
TEXT
>
ID
SECTION
TOPIC
SYNTAX
TEXT
>
-- ---------------- ----- ----------------------- ----------------------------------------------------
>
-- ---------------- ----- ----------------------- ----------------------------------------------------
>
6
4
Commands
(
Other
)
HELP
HELP
[
anything
[...]
]
Displays
the
help
pages
of
SQL
commands
or
keywords
.
>
6
5
Commands
(
Other
)
HELP
HELP
[
anything
[...]
]
Displays
the
help
pages
of
SQL
commands
or
keywords
.
>
rows
:
1
>
rows
:
1
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论