Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6c6fc7eb
提交
6c6fc7eb
authored
1月 18, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ALTER TABLE ALTER COLUMN DROP DEFAULT is a part of standard
上级
a7c139bd
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
37 行增加
和
10 行删除
+37
-10
help.csv
h2/src/docsrc/help/help.csv
+4
-3
CommandInterface.java
h2/src/main/org/h2/command/CommandInterface.java
+2
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+1
-3
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+3
-3
alterTableAlterColumn.sql
...rc/test/org/h2/test/scripts/ddl/alterTableAlterColumn.sql
+27
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
6c6fc7eb
...
...
@@ -355,11 +355,12 @@ ALTER TABLE [ IF EXISTS ] tableName ALTER COLUMN columnName
| { RESTART WITH long }
| { SELECTIVITY int }
| { SET DEFAULT expression }
| { DROP DEFAULT }
| { SET ON UPDATE expression }
| { SET NULL }
| { SET NOT NULL }
| { SET { VISIBLE | INVISIBLE } }
| { DROP
{ DEFAULT | ON UPDATE }
} }
| { DROP
ON UPDATE
} }
","
Changes the data type of a column, rename a column,
change the identity value, or change the selectivity.
...
...
@@ -377,6 +378,8 @@ Selectivity 100 means values are unique, 10 means every distinct value appears 1
SET DEFAULT changes the default value of a column.
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.
...
...
@@ -387,8 +390,6 @@ SET NOT NULL sets a column to not allow NULL. Rows may not contains NULL in this
SET INVISIBLE makes the column hidden, i.e. it will not appear in SELECT * results.
SET VISIBLE has the reverse effect.
DROP DEFAULT removes the default value of a column.
DROP ON UPDATE removes the value that is set on update of a column.
This command commits an open transaction in this connection.
...
...
h2/src/main/org/h2/command/CommandInterface.java
浏览文件 @
6c6fc7eb
...
...
@@ -68,7 +68,8 @@ public interface CommandInterface {
int
ALTER_TABLE_ALTER_COLUMN_NULL
=
9
;
/**
* The type of a ALTER TABLE ALTER COLUMN SET DEFAULT statement.
* The type of a ALTER TABLE ALTER COLUMN SET DEFAULT and ALTER TABLE ALTER
* COLUMN DROP DEFAULT statements.
*/
int
ALTER_TABLE_ALTER_COLUMN_DEFAULT
=
10
;
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
6c6fc7eb
...
...
@@ -7247,10 +7247,8 @@ public class Parser {
command
.
setNewColumnName
(
newName
);
return
command
;
}
else
if
(
readIf
(
"DROP"
))
{
// PostgreSQL compatibility
if
(
readIf
(
"DEFAULT"
))
{
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
schema
);
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
schema
);
command
.
setTableName
(
tableName
);
command
.
setIfTableExists
(
ifTableExists
);
command
.
setOldColumn
(
column
);
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
6c6fc7eb
...
...
@@ -152,9 +152,9 @@ public class TestScript extends TestDb {
"uuid"
,
"varchar"
,
"varchar-ignorecase"
})
{
testScript
(
"datatypes/"
+
s
+
".sql"
);
}
for
(
String
s
:
new
String
[]
{
"alterTableAdd"
,
"alterTable
DropColumn"
,
"alterTableRename
"
,
"
createAlias"
,
"createSequence"
,
"createSynonym"
,
"createTable"
,
"createTrigger"
,
"createView
"
,
"dropDomain"
,
"dropIndex"
,
"dropSchema"
,
"truncateTable"
})
{
for
(
String
s
:
new
String
[]
{
"alterTableAdd"
,
"alterTable
AlterColumn"
,
"alterTableDropColumn
"
,
"
alterTableRename"
,
"createAlias"
,
"createSequence"
,
"createSynonym"
,
"createTable"
,
"createTrigger
"
,
"
createView"
,
"
dropDomain"
,
"dropIndex"
,
"dropSchema"
,
"truncateTable"
})
{
testScript
(
"ddl/"
+
s
+
".sql"
);
}
for
(
String
s
:
new
String
[]
{
"delete"
,
"error_reporting"
,
"insert"
,
"insertIgnore"
,
"merge"
,
"mergeUsing"
,
...
...
h2/src/test/org/h2/test/scripts/ddl/alterTableAlterColumn.sql
0 → 100644
浏览文件 @
6c6fc7eb
-- Copyright 2004-2019 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
(
T
INT
);
>
ok
SELECT
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
COLUMN_NAME
=
'T'
;
>>
INT
-- SET DEFAULT
ALTER
TABLE
TEST
ALTER
COLUMN
T
SET
DEFAULT
1
;
>
ok
SELECT
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
COLUMN_NAME
=
'T'
;
>>
INT
DEFAULT
1
-- DROP DEFAULT
ALTER
TABLE
TEST
ALTER
COLUMN
T
DROP
DEFAULT
;
>
ok
SELECT
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
COLUMN_NAME
=
'T'
;
>>
INT
DROP
TABLE
TEST
;
>
ok
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论