Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c593e188
提交
c593e188
authored
7月 19, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ALTER VIEW RENAME command for better compatibilty
上级
7e3ef0c6
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
93 行增加
和
11 行删除
+93
-11
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
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
c593e188
...
@@ -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
浏览文件 @
c593e188
...
@@ -5767,19 +5767,31 @@ public class Parser {
...
@@ -5767,19 +5767,31 @@ 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
);
}
}
TableView
view
=
(
TableView
)
tableView
;
if
(
readIf
(
"RENAME"
))
{
command
.
setView
(
view
);
read
(
"TO"
);
read
(
"RECOMPILE"
);
String
newName
=
readIdentifierWithSchema
(
schema
.
getName
());
return
command
;
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
;
AlterView
command
=
new
AlterView
(
session
);
command
.
setIfExists
(
ifExists
);
command
.
setView
(
view
);
return
command
;
}
}
}
private
Prepared
parseAlterSchema
()
{
private
Prepared
parseAlterSchema
()
{
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
c593e188
...
@@ -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
浏览文件 @
c593e188
-- 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
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论