Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3617e3f7
Unverified
提交
3617e3f7
authored
3月 09, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
3月 09, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #948 from katzyn/ddl
Fix some grammar descriptions and ALTER TABLE DROP COLUMN parsing
上级
15bfa6c9
8f718a57
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
96 行增加
和
25 行删除
+96
-25
help.csv
h2/src/docsrc/help/help.csv
+5
-5
Parser.java
h2/src/main/org/h2/command/Parser.java
+10
-10
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+1
-1
alterTableDropColumn.sql
h2/src/test/org/h2/test/scripts/ddl/alterTableDropColumn.sql
+80
-0
testScript.sql
h2/src/test/org/h2/test/scripts/testScript.sql
+0
-9
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
3617e3f7
...
@@ -227,9 +227,8 @@ SHOW TABLES
...
@@ -227,9 +227,8 @@ SHOW TABLES
"
"
"Commands (DML)","WITH","
"Commands (DML)","WITH","
WITH [ RECURSIVE ] { name [( columnName [,...] )]
WITH [ RECURSIVE ] { name [( columnName [,...] )] AS ( select ) [,...] }
AS ( select ) [,...] }
{ select | insert | update | merge | delete | createTable }
{ select | insert | update | merge | delete | createTable }
","
","
Can be used to create a recursive or non-recursive query (common table expression).
Can be used to create a recursive or non-recursive query (common table expression).
For recursive queries the first select has to be a UNION.
For recursive queries the first select has to be a UNION.
...
@@ -373,13 +372,14 @@ ALTER TABLE TEST ALTER COLUMN NAME SET INVISIBLE;
...
@@ -373,13 +372,14 @@ ALTER TABLE TEST ALTER COLUMN NAME SET INVISIBLE;
"Commands (DDL)","ALTER TABLE DROP COLUMN","
"Commands (DDL)","ALTER TABLE DROP COLUMN","
ALTER TABLE [ IF EXISTS ] tableName DROP COLUMN [ IF EXISTS ]
ALTER TABLE [ IF EXISTS ] tableName DROP COLUMN [ IF EXISTS ]
( columnName [,...] )
columnName [,...] |
( columnName [,...] )
","
","
Removes column(s) from a table.
Removes column(s) from a table.
This command commits an open transaction in this connection.
This command commits an open transaction in this connection.
","
","
ALTER TABLE TEST DROP COLUMN NAME
ALTER TABLE TEST DROP COLUMN NAME
ALTER TABLE TEST DROP COLUMN NAME1, NAME2
ALTER TABLE TEST DROP COLUMN NAME1, NAME2
ALTER TABLE TEST DROP COLUMN (NAME1, NAME2)
"
"
"Commands (DDL)","ALTER TABLE DROP CONSTRAINT","
"Commands (DDL)","ALTER TABLE DROP CONSTRAINT","
...
@@ -394,7 +394,7 @@ ALTER TABLE TEST DROP CONSTRAINT UNIQUE_NAME
...
@@ -394,7 +394,7 @@ ALTER TABLE TEST DROP CONSTRAINT UNIQUE_NAME
"Commands (DDL)","ALTER TABLE SET","
"Commands (DDL)","ALTER TABLE SET","
ALTER TABLE [ IF EXISTS ] tableName SET REFERENTIAL_INTEGRITY
ALTER TABLE [ IF EXISTS ] tableName SET REFERENTIAL_INTEGRITY
{ FALSE | TRUE [ CHECK | NOCHECK ] }
{ FALSE | TRUE } [ CHECK | NOCHECK ]
","
","
Disables or enables referential integrity checking for a table. This command can
Disables or enables referential integrity checking for a table. This command can
be used inside a transaction. Enabling referential integrity does not check
be used inside a transaction. Enabling referential integrity does not check
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
3617e3f7
...
@@ -6103,28 +6103,28 @@ public class Parser {
...
@@ -6103,28 +6103,28 @@ public class Parser {
}
else
{
}
else
{
readIf
(
"COLUMN"
);
readIf
(
"COLUMN"
);
boolean
ifExists
=
readIfExists
(
false
);
boolean
ifExists
=
readIfExists
(
false
);
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
schema
);
command
.
setType
(
CommandInterface
.
ALTER_TABLE_DROP_COLUMN
);
ArrayList
<
Column
>
columnsToRemove
=
New
.
arrayList
();
ArrayList
<
Column
>
columnsToRemove
=
New
.
arrayList
();
Table
table
=
tableIfTableExists
(
schema
,
tableName
,
ifTableExists
);
Table
table
=
tableIfTableExists
(
schema
,
tableName
,
ifTableExists
);
// For Oracle compatibility - open bracket required
// For Oracle compatibility - open bracket required
boolean
openingBracketDetected
=
readIf
(
"("
);
boolean
openingBracketDetected
=
readIf
(
"("
);
do
{
do
{
String
columnName
=
readColumnIdentifier
();
String
columnName
=
readColumnIdentifier
();
if
(
table
==
null
)
{
if
(
table
!=
null
)
{
return
new
NoOperation
(
session
);
if
(!
ifExists
||
table
.
doesColumnExist
(
columnName
))
{
}
if
(
ifExists
&&
!
table
.
doesColumnExist
(
columnName
))
{
return
new
NoOperation
(
session
);
}
Column
column
=
table
.
getColumn
(
columnName
);
Column
column
=
table
.
getColumn
(
columnName
);
columnsToRemove
.
add
(
column
);
columnsToRemove
.
add
(
column
);
}
}
}
while
(
readIf
(
","
));
}
while
(
readIf
(
","
));
if
(
openingBracketDetected
)
{
if
(
openingBracketDetected
)
{
// For Oracle compatibility - close bracket
// For Oracle compatibility - close bracket
read
(
")"
);
read
(
")"
);
}
}
if
(
table
==
null
||
columnsToRemove
.
isEmpty
())
{
return
new
NoOperation
(
session
);
}
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
schema
);
command
.
setType
(
CommandInterface
.
ALTER_TABLE_DROP_COLUMN
);
command
.
setTableName
(
tableName
);
command
.
setTableName
(
tableName
);
command
.
setIfTableExists
(
ifTableExists
);
command
.
setIfTableExists
(
ifTableExists
);
command
.
setColumnsToRemove
(
columnsToRemove
);
command
.
setColumnsToRemove
(
columnsToRemove
);
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
3617e3f7
...
@@ -101,7 +101,7 @@ public class TestScript extends TestBase {
...
@@ -101,7 +101,7 @@ public class TestScript extends TestBase {
"uuid"
,
"varchar"
,
"varchar-ignorecase"
})
{
"uuid"
,
"varchar"
,
"varchar-ignorecase"
})
{
testScript
(
"datatypes/"
+
s
+
".sql"
);
testScript
(
"datatypes/"
+
s
+
".sql"
);
}
}
for
(
String
s
:
new
String
[]
{
"alterTableAdd"
,
"createView"
,
"dropSchema"
})
{
for
(
String
s
:
new
String
[]
{
"alterTableAdd"
,
"
alterTableDropColumn"
,
"
createView"
,
"dropSchema"
})
{
testScript
(
"ddl/"
+
s
+
".sql"
);
testScript
(
"ddl/"
+
s
+
".sql"
);
}
}
for
(
String
s
:
new
String
[]
{
"insertIgnore"
,
"mergeUsing"
,
"script"
,
"with"
})
{
for
(
String
s
:
new
String
[]
{
"insertIgnore"
,
"mergeUsing"
,
"script"
,
"with"
})
{
...
...
h2/src/test/org/h2/test/scripts/ddl/alterTableDropColumn.sql
0 → 100644
浏览文件 @
3617e3f7
-- 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
(
A
VARCHAR
,
B
VARCHAR
,
C
VARCHAR
AS
LOWER
(
A
));
>
ok
ALTER
TABLE
TEST
DROP
COLUMN
B
;
>
ok
DROP
TABLE
TEST
;
>
ok
ALTER
TABLE
IF
EXISTS
TEST
DROP
COLUMN
A
;
>
ok
ALTER
TABLE
TEST
DROP
COLUMN
A
;
>
exception
CREATE
TABLE
TEST
(
A
INT
,
B
INT
,
C
INT
,
D
INT
,
E
INT
,
F
INT
,
G
INT
,
H
INT
,
I
INT
,
J
INT
);
>
ok
ALTER
TABLE
TEST
DROP
COLUMN
IF
EXISTS
J
;
>
ok
ALTER
TABLE
TEST
DROP
COLUMN
J
;
>
exception
ALTER
TABLE
TEST
DROP
COLUMN
B
;
>
ok
ALTER
TABLE
TEST
DROP
COLUMN
IF
EXISTS
C
;
>
ok
SELECT
*
FROM
TEST
;
>
A
D
E
F
G
H
I
>
-
-
-
-
-
-
-
>
rows
:
0
ALTER
TABLE
TEST
DROP
COLUMN
B
,
D
;
>
exception
ALTER
TABLE
TEST
DROP
COLUMN
IF
EXISTS
B
,
D
;
>
ok
SELECT
*
FROM
TEST
;
>
A
E
F
G
H
I
>
-
-
-
-
-
-
>
rows
:
0
ALTER
TABLE
TEST
DROP
COLUMN
E
,
F
;
>
ok
SELECT
*
FROM
TEST
;
>
A
G
H
I
>
-
-
-
-
>
rows
:
0
ALTER
TABLE
TEST
DROP
COLUMN
(
B
,
H
);
>
exception
ALTER
TABLE
TEST
DROP
COLUMN
IF
EXISTS
(
B
,
H
);
>
ok
SELECT
*
FROM
TEST
;
>
A
G
I
>
-
-
-
>
rows
:
0
ALTER
TABLE
TEST
DROP
COLUMN
(
G
,
I
);
>
ok
SELECT
*
FROM
TEST
;
>
A
>
-
>
rows
:
0
DROP
TABLE
TEST
;
>
ok
h2/src/test/org/h2/test/scripts/testScript.sql
浏览文件 @
3617e3f7
...
@@ -2241,15 +2241,6 @@ select * from (select 1), (select 2);
...
@@ -2241,15 +2241,6 @@ select * from (select 1), (select 2);
> 1 2
> 1 2
> rows: 1
> rows: 1
CREATE TABLE TEST(A VARCHAR, B VARCHAR, C VARCHAR AS LOWER(A));
> ok
ALTER TABLE TEST DROP COLUMN B;
> ok
DROP TABLE TEST;
> ok
create table t1(c1 int, c2 int);
create table t1(c1 int, c2 int);
> ok
> ok
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论