Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
56b472bd
提交
56b472bd
authored
1月 18, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Document ALTER TABLE ALTER COLUMN DROP NOT NULL and remove incorrect information
上级
6c6fc7eb
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
33 行增加
和
10 行删除
+33
-10
help.csv
h2/src/docsrc/help/help.csv
+3
-4
CommandInterface.java
h2/src/main/org/h2/command/CommandInterface.java
+2
-2
Parser.java
h2/src/main/org/h2/command/Parser.java
+3
-3
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+1
-1
alterTableAlterColumn.sql
...rc/test/org/h2/test/scripts/ddl/alterTableAlterColumn.sql
+24
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
56b472bd
...
...
@@ -357,8 +357,8 @@ ALTER TABLE [ IF EXISTS ] tableName ALTER COLUMN columnName
| { SET DEFAULT expression }
| { DROP DEFAULT }
| { SET ON UPDATE expression }
| { SET NULL }
| { SET NOT NULL }
| { DROP NOT NULL } | { SET NULL }
| { SET { VISIBLE | INVISIBLE } }
| { DROP ON UPDATE } }
","
...
...
@@ -382,11 +382,10 @@ DROP DEFAULT removes the default value of a column.
SET ON UPDATE changes the value that is set on update if value for this column is not specified in update statement.
SET NULL sets a column to allow NULL. The row may not be part of a primary key.
Single column indexes on this column are dropped.
SET NOT NULL sets a column to not allow NULL. Rows may not contains NULL in this column.
DROP NOT NULL and SET NULL set a column to allow NULL. The row may not be part of a primary key.
SET INVISIBLE makes the column hidden, i.e. it will not appear in SELECT * results.
SET VISIBLE has the reverse effect.
...
...
h2/src/main/org/h2/command/CommandInterface.java
浏览文件 @
56b472bd
...
...
@@ -63,9 +63,9 @@ public interface CommandInterface {
int
ALTER_TABLE_ALTER_COLUMN_NOT_NULL
=
8
;
/**
* The type of a ALTER TABLE ALTER COLUMN
SE
T NULL statement.
* The type of a ALTER TABLE ALTER COLUMN
DROP NO
T NULL statement.
*/
int
ALTER_TABLE_ALTER_COLUMN_NULL
=
9
;
int
ALTER_TABLE_ALTER_COLUMN_
DROP_NOT_
NULL
=
9
;
/**
* The type of a ALTER TABLE ALTER COLUMN SET DEFAULT and ALTER TABLE ALTER
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
56b472bd
...
...
@@ -7216,7 +7216,7 @@ public class Parser {
Column
column
=
columnIfTableExists
(
schema
,
tableName
,
columnName
,
ifTableExists
);
command
.
setOldColumn
(
column
);
if
(
nullConstraint
==
NullConstraintType
.
NULL_IS_ALLOWED
)
{
command
.
setType
(
CommandInterface
.
ALTER_TABLE_ALTER_COLUMN_NULL
);
command
.
setType
(
CommandInterface
.
ALTER_TABLE_ALTER_COLUMN_
DROP_NOT_
NULL
);
}
else
{
command
.
setType
(
CommandInterface
.
ALTER_TABLE_ALTER_COLUMN_NOT_NULL
);
}
...
...
@@ -7273,7 +7273,7 @@ public class Parser {
command
.
setTableName
(
tableName
);
command
.
setIfTableExists
(
ifTableExists
);
command
.
setOldColumn
(
column
);
command
.
setType
(
CommandInterface
.
ALTER_TABLE_ALTER_COLUMN_NULL
);
command
.
setType
(
CommandInterface
.
ALTER_TABLE_ALTER_COLUMN_
DROP_NOT_
NULL
);
return
command
;
}
else
if
(
readIf
(
"TYPE"
))
{
// PostgreSQL compatibility
...
...
@@ -7294,7 +7294,7 @@ public class Parser {
NullConstraintType
nullConstraint
=
parseNotNullConstraint
();
switch
(
nullConstraint
)
{
case
NULL_IS_ALLOWED:
command
.
setType
(
CommandInterface
.
ALTER_TABLE_ALTER_COLUMN_NULL
);
command
.
setType
(
CommandInterface
.
ALTER_TABLE_ALTER_COLUMN_
DROP_NOT_
NULL
);
break
;
case
NULL_IS_NOT_ALLOWED:
command
.
setType
(
CommandInterface
.
ALTER_TABLE_ALTER_COLUMN_NOT_NULL
);
...
...
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
56b472bd
...
...
@@ -137,7 +137,7 @@ public class AlterTableAlterColumn extends CommandWithColumns {
db
.
updateMeta
(
session
,
table
);
break
;
}
case
CommandInterface
.
ALTER_TABLE_ALTER_COLUMN_NULL
:
{
case
CommandInterface
.
ALTER_TABLE_ALTER_COLUMN_
DROP_NOT_
NULL
:
{
if
(
oldColumn
.
isNullable
())
{
// no change
break
;
...
...
h2/src/test/org/h2/test/scripts/ddl/alterTableAlterColumn.sql
浏览文件 @
56b472bd
...
...
@@ -23,5 +23,29 @@ ALTER TABLE TEST ALTER COLUMN T DROP DEFAULT;
SELECT
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
COLUMN_NAME
=
'T'
;
>>
INT
-- SET NOT NULL
ALTER
TABLE
TEST
ALTER
COLUMN
T
SET
NOT
NULL
;
>
ok
SELECT
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
COLUMN_NAME
=
'T'
;
>>
INT
NOT
NULL
-- DROP NOT NULL
ALTER
TABLE
TEST
ALTER
COLUMN
T
DROP
NOT
NULL
;
>
ok
SELECT
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
COLUMN_NAME
=
'T'
;
>>
INT
ALTER
TABLE
TEST
ALTER
COLUMN
T
SET
NOT
NULL
;
>
ok
-- SET NULL
ALTER
TABLE
TEST
ALTER
COLUMN
T
SET
NULL
;
>
ok
SELECT
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
COLUMN_NAME
=
'T'
;
>>
INT
DROP
TABLE
TEST
;
>
ok
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论