Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
cc021a06
Unverified
提交
cc021a06
authored
2月 28, 2018
作者:
Noel Grandin
提交者:
GitHub
2月 28, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #911 from katzyn/ddl
Add support for MySQL-style ALTER TABLE ADD ... FIRST
上级
c7668d41
6e9c1e39
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
65 行增加
和
7 行删除
+65
-7
help.csv
h2/src/docsrc/help/help.csv
+1
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+2
-0
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+8
-1
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+6
-5
alterTableAdd.sql
h2/src/test/org/h2/test/scripts/ddl/alterTableAdd.sql
+48
-0
createView.sql
h2/src/test/org/h2/test/scripts/ddl/createView.sql
+0
-0
script.sql
h2/src/test/org/h2/test/scripts/dml/script.sql
+0
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
cc021a06
...
...
@@ -285,7 +285,7 @@ ALTER SEQUENCE SEQ_ID RESTART WITH 1000
"Commands (DDL)","ALTER TABLE ADD","
ALTER TABLE [ IF EXISTS ] tableName ADD [ COLUMN ]
{ [ IF NOT EXISTS ] columnName columnDefinition | ( { columnName columnDefinition } [,...] ) }
[ {
BEFORE | AFTER } columnName
]
[ {
{ BEFORE | AFTER } columnName } | FIRST
]
","
Adds a new column to a table.
This command commits an open transaction in this connection.
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
cc021a06
...
...
@@ -6289,6 +6289,8 @@ public class Parser {
command
.
setAddBefore
(
readColumnIdentifier
());
}
else
if
(
readIf
(
"AFTER"
))
{
command
.
setAddAfter
(
readColumnIdentifier
());
}
else
if
(
readIf
(
"FIRST"
))
{
command
.
setAddFirst
();
}
command
.
setNewColumns
(
columnsToAdd
);
return
command
;
...
...
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
cc021a06
...
...
@@ -56,6 +56,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
private
int
type
;
private
Expression
defaultExpression
;
private
Expression
newSelectivity
;
private
boolean
addFirst
;
private
String
addBefore
;
private
String
addAfter
;
private
boolean
ifTableExists
;
...
...
@@ -80,6 +81,10 @@ public class AlterTableAlterColumn extends SchemaCommand {
this
.
oldColumn
=
oldColumn
;
}
public
void
setAddFirst
()
{
addFirst
=
true
;
}
public
void
setAddBefore
(
String
before
)
{
this
.
addBefore
=
before
;
}
...
...
@@ -331,7 +336,9 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
}
else
if
(
type
==
CommandInterface
.
ALTER_TABLE_ADD_COLUMN
)
{
int
position
;
if
(
addBefore
!=
null
)
{
if
(
addFirst
)
{
position
=
0
;
}
else
if
(
addBefore
!=
null
)
{
position
=
table
.
getColumn
(
addBefore
).
getColumnId
();
}
else
if
(
addAfter
!=
null
)
{
position
=
table
.
getColumn
(
addAfter
).
getColumnId
()
+
1
;
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
cc021a06
...
...
@@ -86,8 +86,6 @@ public class TestScript extends TestBase {
testScript
(
"joins.sql"
);
testScript
(
"altertable-index-reuse.sql"
);
testScript
(
"query-optimisations.sql"
);
testScript
(
"commands-dml-script.sql"
);
testScript
(
"commands-dml-create-view.sql"
);
String
decimal2
;
if
(
SysProperties
.
BIG_DECIMAL_IS_DECIMAL
)
{
decimal2
=
"decimal_decimal"
;
...
...
@@ -102,6 +100,12 @@ public class TestScript extends TestBase {
"uuid"
,
"varchar"
,
"varchar-ignorecase"
})
{
testScript
(
"datatypes/"
+
s
+
".sql"
);
}
for
(
String
s
:
new
String
[]
{
"alterTableAdd"
,
"createView"
})
{
testScript
(
"ddl/"
+
s
+
".sql"
);
}
for
(
String
s
:
new
String
[]
{
"insertIgnore"
,
"mergeUsing"
,
"script"
,
"with"
})
{
testScript
(
"dml/"
+
s
+
".sql"
);
}
for
(
String
s
:
new
String
[]
{
"avg"
,
"bit-and"
,
"bit-or"
,
"count"
,
"group-concat"
,
"max"
,
"median"
,
"min"
,
"selectivity"
,
"stddev-pop"
,
"stddev-samp"
,
"sum"
,
"var-pop"
,
"var-samp"
})
{
...
...
@@ -145,9 +149,6 @@ public class TestScript extends TestBase {
"parsedatetime"
,
"quarter"
,
"second"
,
"week"
,
"year"
})
{
testScript
(
"functions/timeanddate/"
+
s
+
".sql"
);
}
for
(
String
s
:
new
String
[]
{
"insertIgnore"
,
"mergeUsing"
,
"with"
})
{
testScript
(
"dml/"
+
s
+
".sql"
);
}
deleteDb
(
"script"
);
System
.
out
.
flush
();
}
...
...
h2/src/test/org/h2/test/scripts/ddl/alterTableAdd.sql
0 → 100644
浏览文件 @
cc021a06
-- 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
--
CREATE
TABLE
TEST
(
B
INT
);
>
ok
ALTER
TABLE
TEST
ADD
C
INT
;
>
ok
ALTER
TABLE
TEST
ADD
COLUMN
D
INT
;
>
ok
ALTER
TABLE
TEST
ADD
IF
NOT
EXISTS
B
INT
;
>
ok
ALTER
TABLE
TEST
ADD
IF
NOT
EXISTS
E
INT
;
>
ok
ALTER
TABLE
IF
EXISTS
TEST2
ADD
COLUMN
B
INT
;
>
ok
ALTER
TABLE
TEST
ADD
B1
INT
AFTER
B
;
>
ok
ALTER
TABLE
TEST
ADD
B2
INT
BEFORE
C
;
>
ok
ALTER
TABLE
TEST
ADD
(
C1
INT
,
C2
INT
)
AFTER
C
;
>
ok
ALTER
TABLE
TEST
ADD
(
C3
INT
,
C4
INT
)
BEFORE
D
;
>
ok
ALTER
TABLE
TEST
ADD
A2
INT
FIRST
;
>
ok
ALTER
TABLE
TEST
ADD
(
A
INT
,
A1
INT
)
FIRST
;
>
ok
SELECT
*
FROM
TEST
;
>
A
A1
A2
B
B1
B2
C
C1
C2
C3
C4
D
E
>
-
-- -- - -- -- - -- -- -- -- - -
>
rows
:
0
DROP
TABLE
TEST
;
>
ok
h2/src/test/org/h2/test/scripts/
commands-dml-script
.sql
→
h2/src/test/org/h2/test/scripts/
ddl/createView
.sql
浏览文件 @
cc021a06
File moved
h2/src/test/org/h2/test/scripts/
commands-dml-create-view
.sql
→
h2/src/test/org/h2/test/scripts/
dml/script
.sql
浏览文件 @
cc021a06
File moved
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论