Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6c7cf723
提交
6c7cf723
authored
7月 05, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Preserve domain name in columns
上级
61eee27c
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
112 行增加
和
32 行删除
+112
-32
help.csv
h2/src/docsrc/help/help.csv
+3
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+24
-24
DropUserDataType.java
h2/src/main/org/h2/command/ddl/DropUserDataType.java
+27
-0
DbSettings.java
h2/src/main/org/h2/engine/DbSettings.java
+2
-2
Column.java
h2/src/main/org/h2/table/Column.java
+10
-0
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+1
-1
dropDomain.sql
h2/src/test/org/h2/test/scripts/ddl/dropDomain.sql
+38
-0
testScript.sql
h2/src/test/org/h2/test/scripts/testScript.sql
+7
-4
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
6c7cf723
...
@@ -884,9 +884,11 @@ DROP CONSTANT ONE
...
@@ -884,9 +884,11 @@ DROP CONSTANT ONE
"
"
"Commands (DDL)","DROP DOMAIN","
"Commands (DDL)","DROP DOMAIN","
DROP DOMAIN [ IF EXISTS ] domainName
DROP DOMAIN [ IF EXISTS ] domainName
[ RESTRICT | CASCADE ]
","
","
Drops a data type (domain).
Drops a data type (domain).
The command will fail if it is referenced by a column (the default).
Column descriptors are replaced with original definition of specified domain if the CASCADE clause is used.
This command commits an open transaction in this connection.
This command commits an open transaction in this connection.
","
","
DROP DOMAIN EMAIL
DROP DOMAIN EMAIL
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
6c7cf723
...
@@ -649,7 +649,7 @@ public class Parser {
...
@@ -649,7 +649,7 @@ public class Parser {
if
(
readIf
(
"("
))
{
if
(
readIf
(
"("
))
{
ArrayList
<
Column
>
list
=
Utils
.
newSmallArrayList
();
ArrayList
<
Column
>
list
=
Utils
.
newSmallArrayList
();
for
(
int
i
=
0
;;
i
++)
{
for
(
int
i
=
0
;;
i
++)
{
Column
column
=
parseColumnForTable
(
"C"
+
i
,
true
);
Column
column
=
parseColumnForTable
(
"C"
+
i
,
true
,
false
);
list
.
add
(
column
);
list
.
add
(
column
);
if
(!
readIfMore
(
true
))
{
if
(!
readIfMore
(
true
))
{
break
;
break
;
...
@@ -1789,11 +1789,7 @@ public class Parser {
...
@@ -1789,11 +1789,7 @@ public class Parser {
command
.
setDeleteFiles
(
true
);
command
.
setDeleteFiles
(
true
);
}
}
return
command
;
return
command
;
}
else
if
(
readIf
(
"DOMAIN"
))
{
}
else
if
(
readIf
(
"DOMAIN"
)
||
readIf
(
"TYPE"
)
||
readIf
(
"DATATYPE"
))
{
return
parseDropUserDataType
();
}
else
if
(
readIf
(
"TYPE"
))
{
return
parseDropUserDataType
();
}
else
if
(
readIf
(
"DATATYPE"
))
{
return
parseDropUserDataType
();
return
parseDropUserDataType
();
}
else
if
(
readIf
(
"AGGREGATE"
))
{
}
else
if
(
readIf
(
"AGGREGATE"
))
{
return
parseDropAggregate
();
return
parseDropAggregate
();
...
@@ -1815,6 +1811,11 @@ public class Parser {
...
@@ -1815,6 +1811,11 @@ public class Parser {
command
.
setTypeName
(
readUniqueIdentifier
());
command
.
setTypeName
(
readUniqueIdentifier
());
ifExists
=
readIfExists
(
ifExists
);
ifExists
=
readIfExists
(
ifExists
);
command
.
setIfExists
(
ifExists
);
command
.
setIfExists
(
ifExists
);
if
(
readIf
(
"CASCADE"
))
{
command
.
setDropAction
(
ConstraintActionType
.
CASCADE
);
}
else
if
(
readIf
(
"RESTRICT"
))
{
command
.
setDropAction
(
ConstraintActionType
.
RESTRICT
);
}
return
command
;
return
command
;
}
}
...
@@ -2804,14 +2805,14 @@ public class Parser {
...
@@ -2804,14 +2805,14 @@ public class Parser {
case
Function
.
CAST
:
{
case
Function
.
CAST
:
{
function
.
setParameter
(
0
,
readExpression
());
function
.
setParameter
(
0
,
readExpression
());
read
(
"AS"
);
read
(
"AS"
);
Column
type
=
parseColumnWithType
(
null
);
Column
type
=
parseColumnWithType
(
null
,
false
);
function
.
setDataType
(
type
);
function
.
setDataType
(
type
);
read
(
")"
);
read
(
")"
);
break
;
break
;
}
}
case
Function
.
CONVERT
:
{
case
Function
.
CONVERT
:
{
if
(
database
.
getMode
().
swapConvertFunctionParameters
)
{
if
(
database
.
getMode
().
swapConvertFunctionParameters
)
{
Column
type
=
parseColumnWithType
(
null
);
Column
type
=
parseColumnWithType
(
null
,
false
);
function
.
setDataType
(
type
);
function
.
setDataType
(
type
);
read
(
","
);
read
(
","
);
function
.
setParameter
(
0
,
readExpression
());
function
.
setParameter
(
0
,
readExpression
());
...
@@ -2819,7 +2820,7 @@ public class Parser {
...
@@ -2819,7 +2820,7 @@ public class Parser {
}
else
{
}
else
{
function
.
setParameter
(
0
,
readExpression
());
function
.
setParameter
(
0
,
readExpression
());
read
(
","
);
read
(
","
);
Column
type
=
parseColumnWithType
(
null
);
Column
type
=
parseColumnWithType
(
null
,
false
);
function
.
setDataType
(
type
);
function
.
setDataType
(
type
);
read
(
")"
);
read
(
")"
);
}
}
...
@@ -2926,7 +2927,7 @@ public class Parser {
...
@@ -2926,7 +2927,7 @@ public class Parser {
ArrayList
<
Column
>
columns
=
Utils
.
newSmallArrayList
();
ArrayList
<
Column
>
columns
=
Utils
.
newSmallArrayList
();
do
{
do
{
String
columnName
=
readAliasIdentifier
();
String
columnName
=
readAliasIdentifier
();
Column
column
=
parseColumnWithType
(
columnName
);
Column
column
=
parseColumnWithType
(
columnName
,
false
);
columns
.
add
(
column
);
columns
.
add
(
column
);
read
(
"="
);
read
(
"="
);
function
.
setParameter
(
i
,
readExpression
());
function
.
setParameter
(
i
,
readExpression
());
...
@@ -3368,7 +3369,7 @@ public class Parser {
...
@@ -3368,7 +3369,7 @@ public class Parser {
Expression
[]
args
=
{
r
};
Expression
[]
args
=
{
r
};
r
=
new
JavaFunction
(
f
,
args
);
r
=
new
JavaFunction
(
f
,
args
);
}
else
{
}
else
{
Column
col
=
parseColumnWithType
(
null
);
Column
col
=
parseColumnWithType
(
null
,
false
);
Function
function
=
Function
.
getFunction
(
database
,
"CAST"
);
Function
function
=
Function
.
getFunction
(
database
,
"CAST"
);
function
.
setDataType
(
col
);
function
.
setDataType
(
col
);
function
.
setParameter
(
0
,
r
);
function
.
setParameter
(
0
,
r
);
...
@@ -4212,7 +4213,7 @@ public class Parser {
...
@@ -4212,7 +4213,7 @@ public class Parser {
}
}
private
Column
parseColumnForTable
(
String
columnName
,
private
Column
parseColumnForTable
(
String
columnName
,
boolean
defaultNullable
)
{
boolean
defaultNullable
,
boolean
forTable
)
{
Column
column
;
Column
column
;
boolean
isIdentity
=
readIf
(
"IDENTITY"
);
boolean
isIdentity
=
readIf
(
"IDENTITY"
);
if
(
isIdentity
||
readIf
(
"BIGSERIAL"
))
{
if
(
isIdentity
||
readIf
(
"BIGSERIAL"
))
{
...
@@ -4238,7 +4239,7 @@ public class Parser {
...
@@ -4238,7 +4239,7 @@ public class Parser {
column
.
setPrimaryKey
(
true
);
column
.
setPrimaryKey
(
true
);
}
}
}
else
{
}
else
{
column
=
parseColumnWithType
(
columnName
);
column
=
parseColumnWithType
(
columnName
,
forTable
);
}
}
if
(
readIf
(
"INVISIBLE"
))
{
if
(
readIf
(
"INVISIBLE"
))
{
column
.
setVisible
(
false
);
column
.
setVisible
(
false
);
...
@@ -4346,7 +4347,7 @@ public class Parser {
...
@@ -4346,7 +4347,7 @@ public class Parser {
return
null
;
return
null
;
}
}
private
Column
parseColumnWithType
(
String
columnName
)
{
private
Column
parseColumnWithType
(
String
columnName
,
boolean
forTable
)
{
String
original
=
currentToken
;
String
original
=
currentToken
;
boolean
regular
=
false
;
boolean
regular
=
false
;
int
originalScale
=
-
1
;
int
originalScale
=
-
1
;
...
@@ -4414,7 +4415,7 @@ public class Parser {
...
@@ -4414,7 +4415,7 @@ public class Parser {
templateColumn
=
userDataType
.
getColumn
();
templateColumn
=
userDataType
.
getColumn
();
dataType
=
DataType
.
getDataType
(
templateColumn
.
getType
());
dataType
=
DataType
.
getDataType
(
templateColumn
.
getType
());
comment
=
templateColumn
.
getComment
();
comment
=
templateColumn
.
getComment
();
original
=
templateColumn
.
getOriginalSQL
();
original
=
forTable
?
userDataType
.
getSQL
()
:
templateColumn
.
getOriginalSQL
();
precision
=
templateColumn
.
getPrecision
();
precision
=
templateColumn
.
getPrecision
();
displaySize
=
templateColumn
.
getDisplaySize
();
displaySize
=
templateColumn
.
getDisplaySize
();
scale
=
templateColumn
.
getScale
();
scale
=
templateColumn
.
getScale
();
...
@@ -4584,6 +4585,9 @@ public class Parser {
...
@@ -4584,6 +4585,9 @@ public class Parser {
}
}
column
.
setComment
(
comment
);
column
.
setComment
(
comment
);
column
.
setOriginalSQL
(
original
);
column
.
setOriginalSQL
(
original
);
if
(
forTable
)
{
column
.
setUserDataType
(
userDataType
);
}
return
column
;
return
column
;
}
}
...
@@ -4610,11 +4614,7 @@ public class Parser {
...
@@ -4610,11 +4614,7 @@ public class Parser {
return
parseCreateSchema
();
return
parseCreateSchema
();
}
else
if
(
readIf
(
"CONSTANT"
))
{
}
else
if
(
readIf
(
"CONSTANT"
))
{
return
parseCreateConstant
();
return
parseCreateConstant
();
}
else
if
(
readIf
(
"DOMAIN"
))
{
}
else
if
(
readIf
(
"DOMAIN"
)
||
readIf
(
"TYPE"
)
||
readIf
(
"DATATYPE"
))
{
return
parseCreateUserDataType
();
}
else
if
(
readIf
(
"TYPE"
))
{
return
parseCreateUserDataType
();
}
else
if
(
readIf
(
"DATATYPE"
))
{
return
parseCreateUserDataType
();
return
parseCreateUserDataType
();
}
else
if
(
readIf
(
"AGGREGATE"
))
{
}
else
if
(
readIf
(
"AGGREGATE"
))
{
return
parseCreateAggregate
(
force
);
return
parseCreateAggregate
(
force
);
...
@@ -5030,7 +5030,7 @@ public class Parser {
...
@@ -5030,7 +5030,7 @@ public class Parser {
CreateUserDataType
command
=
new
CreateUserDataType
(
session
);
CreateUserDataType
command
=
new
CreateUserDataType
(
session
);
command
.
setTypeName
(
readUniqueIdentifier
());
command
.
setTypeName
(
readUniqueIdentifier
());
read
(
"AS"
);
read
(
"AS"
);
Column
col
=
parseColumnForTable
(
"VALUE"
,
true
);
Column
col
=
parseColumnForTable
(
"VALUE"
,
true
,
false
);
if
(
readIf
(
"CHECK"
))
{
if
(
readIf
(
"CHECK"
))
{
Expression
expr
=
readExpression
();
Expression
expr
=
readExpression
();
col
.
addCheckConstraint
(
session
,
expr
);
col
.
addCheckConstraint
(
session
,
expr
);
...
@@ -6155,7 +6155,7 @@ public class Parser {
...
@@ -6155,7 +6155,7 @@ public class Parser {
boolean
nullable
=
column
==
null
?
true
:
column
.
isNullable
();
boolean
nullable
=
column
==
null
?
true
:
column
.
isNullable
();
// new column type ignored. RENAME and MODIFY are
// new column type ignored. RENAME and MODIFY are
// a single command in MySQL but two different commands in H2.
// a single command in MySQL but two different commands in H2.
parseColumnForTable
(
newColumnName
,
nullable
);
parseColumnForTable
(
newColumnName
,
nullable
,
true
);
AlterTableRenameColumn
command
=
new
AlterTableRenameColumn
(
session
,
schema
);
AlterTableRenameColumn
command
=
new
AlterTableRenameColumn
(
session
,
schema
);
command
.
setTableName
(
tableName
);
command
.
setTableName
(
tableName
);
command
.
setIfTableExists
(
ifTableExists
);
command
.
setIfTableExists
(
ifTableExists
);
...
@@ -6336,7 +6336,7 @@ public class Parser {
...
@@ -6336,7 +6336,7 @@ public class Parser {
String
tableName
,
String
columnName
,
boolean
ifTableExists
)
{
String
tableName
,
String
columnName
,
boolean
ifTableExists
)
{
Column
oldColumn
=
columnIfTableExists
(
schema
,
tableName
,
columnName
,
ifTableExists
);
Column
oldColumn
=
columnIfTableExists
(
schema
,
tableName
,
columnName
,
ifTableExists
);
Column
newColumn
=
parseColumnForTable
(
columnName
,
Column
newColumn
=
parseColumnForTable
(
columnName
,
oldColumn
==
null
?
true
:
oldColumn
.
isNullable
());
oldColumn
==
null
?
true
:
oldColumn
.
isNullable
()
,
true
);
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
schema
);
schema
);
command
.
setTableName
(
tableName
);
command
.
setTableName
(
tableName
);
...
@@ -6705,7 +6705,7 @@ public class Parser {
...
@@ -6705,7 +6705,7 @@ public class Parser {
command
.
addConstraintCommand
(
c
);
command
.
addConstraintCommand
(
c
);
}
else
{
}
else
{
String
columnName
=
readColumnIdentifier
();
String
columnName
=
readColumnIdentifier
();
Column
column
=
parseColumnForTable
(
columnName
,
true
);
Column
column
=
parseColumnForTable
(
columnName
,
true
,
true
);
if
(
column
.
isAutoIncrement
()
&&
column
.
isPrimaryKey
())
{
if
(
column
.
isAutoIncrement
()
&&
column
.
isPrimaryKey
())
{
column
.
setPrimaryKey
(
false
);
column
.
setPrimaryKey
(
false
);
IndexColumn
[]
cols
=
{
new
IndexColumn
()
};
IndexColumn
[]
cols
=
{
new
IndexColumn
()
};
...
...
h2/src/main/org/h2/command/ddl/DropUserDataType.java
浏览文件 @
6c7cf723
...
@@ -7,10 +7,13 @@ package org.h2.command.ddl;
...
@@ -7,10 +7,13 @@ package org.h2.command.ddl;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
import
org.h2.constraint.ConstraintActionType
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.engine.UserDataType
;
import
org.h2.engine.UserDataType
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
/**
/**
* This class represents the statement
* This class represents the statement
...
@@ -20,15 +23,22 @@ public class DropUserDataType extends DefineCommand {
...
@@ -20,15 +23,22 @@ public class DropUserDataType extends DefineCommand {
private
String
typeName
;
private
String
typeName
;
private
boolean
ifExists
;
private
boolean
ifExists
;
private
ConstraintActionType
dropAction
;
public
DropUserDataType
(
Session
session
)
{
public
DropUserDataType
(
Session
session
)
{
super
(
session
);
super
(
session
);
dropAction
=
session
.
getDatabase
().
getSettings
().
dropRestrict
?
ConstraintActionType
.
RESTRICT
:
ConstraintActionType
.
CASCADE
;
}
}
public
void
setIfExists
(
boolean
ifExists
)
{
public
void
setIfExists
(
boolean
ifExists
)
{
this
.
ifExists
=
ifExists
;
this
.
ifExists
=
ifExists
;
}
}
public
void
setDropAction
(
ConstraintActionType
dropAction
)
{
this
.
dropAction
=
dropAction
;
}
@Override
@Override
public
int
update
()
{
public
int
update
()
{
session
.
getUser
().
checkAdmin
();
session
.
getUser
().
checkAdmin
();
...
@@ -40,6 +50,23 @@ public class DropUserDataType extends DefineCommand {
...
@@ -40,6 +50,23 @@ public class DropUserDataType extends DefineCommand {
throw
DbException
.
get
(
ErrorCode
.
USER_DATA_TYPE_NOT_FOUND_1
,
typeName
);
throw
DbException
.
get
(
ErrorCode
.
USER_DATA_TYPE_NOT_FOUND_1
,
typeName
);
}
}
}
else
{
}
else
{
for
(
Table
t
:
db
.
getAllTablesAndViews
(
false
))
{
boolean
modified
=
false
;
for
(
Column
c
:
t
.
getColumns
())
{
UserDataType
udt
=
c
.
getUserDataType
();
if
(
udt
!=
null
&&
udt
.
getName
().
equals
(
typeName
))
{
if
(
dropAction
==
ConstraintActionType
.
RESTRICT
)
{
throw
DbException
.
get
(
ErrorCode
.
CANNOT_DROP_2
,
typeName
,
t
.
getCreateSQL
());
}
c
.
setOriginalSQL
(
type
.
getColumn
().
getOriginalSQL
());
c
.
setUserDataType
(
null
);
modified
=
true
;
}
}
if
(
modified
)
{
db
.
updateMeta
(
session
,
t
);
}
}
db
.
removeDatabaseObject
(
session
,
type
);
db
.
removeDatabaseObject
(
session
,
type
);
}
}
return
0
;
return
0
;
...
...
h2/src/main/org/h2/engine/DbSettings.java
浏览文件 @
6c7cf723
...
@@ -99,8 +99,8 @@ public class DbSettings extends SettingsBase {
...
@@ -99,8 +99,8 @@ public class DbSettings extends SettingsBase {
/**
/**
* Database setting <code>DROP_RESTRICT</code> (default: true).<br />
* Database setting <code>DROP_RESTRICT</code> (default: true).<br />
* Whether the default action for DROP TABLE, DROP VIEW,
and DROP SCHEMA
* Whether the default action for DROP TABLE, DROP VIEW,
DROP SCHEMA, and
* is RESTRICT.
*
DROP DOMAIN
is RESTRICT.
*/
*/
public
final
boolean
dropRestrict
=
get
(
"DROP_RESTRICT"
,
true
);
public
final
boolean
dropRestrict
=
get
(
"DROP_RESTRICT"
,
true
);
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
6c7cf723
...
@@ -12,6 +12,7 @@ import org.h2.command.Parser;
...
@@ -12,6 +12,7 @@ import org.h2.command.Parser;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Mode
;
import
org.h2.engine.Mode
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.engine.UserDataType
;
import
org.h2.expression.ConditionAndOr
;
import
org.h2.expression.ConditionAndOr
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
import
org.h2.expression.ExpressionVisitor
;
import
org.h2.expression.ExpressionVisitor
;
...
@@ -87,6 +88,7 @@ public class Column {
...
@@ -87,6 +88,7 @@ public class Column {
private
String
comment
;
private
String
comment
;
private
boolean
primaryKey
;
private
boolean
primaryKey
;
private
boolean
visible
=
true
;
private
boolean
visible
=
true
;
private
UserDataType
userDataType
;
public
Column
(
String
name
,
int
type
)
{
public
Column
(
String
name
,
int
type
)
{
this
(
name
,
type
,
-
1
,
-
1
,
-
1
,
null
);
this
(
name
,
type
,
-
1
,
-
1
,
-
1
,
null
);
...
@@ -314,6 +316,14 @@ public class Column {
...
@@ -314,6 +316,14 @@ public class Column {
visible
=
b
;
visible
=
b
;
}
}
public
UserDataType
getUserDataType
()
{
return
userDataType
;
}
public
void
setUserDataType
(
UserDataType
userDataType
)
{
this
.
userDataType
=
userDataType
;
}
/**
/**
* Validate the value, convert it if required, and update the sequence value
* Validate the value, convert it if required, and update the sequence value
* if required. If the value is null, the default value (NULL if no default
* if required. If the value is null, the default value (NULL if no default
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
6c7cf723
...
@@ -124,7 +124,7 @@ public class TestScript extends TestDb {
...
@@ -124,7 +124,7 @@ public class TestScript extends TestDb {
}
}
for
(
String
s
:
new
String
[]
{
"alterTableAdd"
,
"alterTableDropColumn"
,
for
(
String
s
:
new
String
[]
{
"alterTableAdd"
,
"alterTableDropColumn"
,
"createAlias"
,
"createSynonym"
,
"createView"
,
"createTable"
,
"createTrigger"
,
"createAlias"
,
"createSynonym"
,
"createView"
,
"createTable"
,
"createTrigger"
,
"dropIndex"
,
"dropSchema"
,
"truncateTable"
})
{
"drop
Domain"
,
"drop
Index"
,
"dropSchema"
,
"truncateTable"
})
{
testScript
(
"ddl/"
+
s
+
".sql"
);
testScript
(
"ddl/"
+
s
+
".sql"
);
}
}
for
(
String
s
:
new
String
[]
{
"error_reporting"
,
"insertIgnore"
,
for
(
String
s
:
new
String
[]
{
"error_reporting"
,
"insertIgnore"
,
...
...
h2/src/test/org/h2/test/scripts/ddl/dropDomain.sql
0 → 100644
浏览文件 @
6c7cf723
-- 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
DOMAIN
E
AS
ENUM
(
'A'
,
'B'
);
>
ok
CREATE
TABLE
TEST
(
I
INT
PRIMARY
KEY
,
E1
E
,
E2
E
NOT
NULL
);
>
ok
INSERT
INTO
TEST
VALUES
(
1
,
'A'
,
'B'
);
>
update
count
:
1
SELECT
COLUMN_NAME
,
NULLABLE
,
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
TABLE_NAME
=
'TEST'
ORDER
BY
ORDINAL_POSITION
;
>
COLUMN_NAME
NULLABLE
COLUMN_TYPE
>
----------- -------- ------------
>
I
0
INT
NOT
NULL
>
E1
1
E
>
E2
0
E
NOT
NULL
>
rows
(
ordered
):
3
DROP
DOMAIN
E
RESTRICT
;
>
exception
CANNOT_DROP_2
DROP
DOMAIN
E
CASCADE
;
>
ok
SELECT
COLUMN_NAME
,
NULLABLE
,
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
TABLE_NAME
=
'TEST'
ORDER
BY
ORDINAL_POSITION
;
>
COLUMN_NAME
NULLABLE
COLUMN_TYPE
>
----------- -------- ----------------------
>
I
0
INT
NOT
NULL
>
E1
1
ENUM
(
'A'
,
'B'
)
>
E2
0
ENUM
(
'A'
,
'B'
)
NOT
NULL
>
rows
(
ordered
):
3
DROP
TABLE
TEST
;
>
ok
h2/src/test/org/h2/test/scripts/testScript.sql
浏览文件 @
6c7cf723
...
@@ -840,10 +840,13 @@ script nodata nopasswords nosettings;
...
@@ -840,10 +840,13 @@ script nodata nopasswords nosettings;
>
-----------------------------------------------
>
-----------------------------------------------
>
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.TEST;
>
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.TEST;
>
CREATE
DOMAIN
INT
AS
VARCHAR
;
>
CREATE
DOMAIN
INT
AS
VARCHAR
;
>
CREATE
MEMORY
TABLE
PUBLIC
.
TEST
(
ID
VARCHAR
);
>
CREATE
MEMORY
TABLE
PUBLIC
.
TEST
(
ID
INT
);
>
CREATE
USER
IF
NOT
EXISTS
SA
PASSWORD
''
ADMIN
;
>
CREATE
USER
IF
NOT
EXISTS
SA
PASSWORD
''
ADMIN
;
>
rows
:
4
>
rows
:
4
SELECT
DATA_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
TABLE_NAME
=
'TEST'
;
>>
12
drop
table
test
;
drop
table
test
;
>
ok
>
ok
...
@@ -2674,7 +2677,7 @@ select DOMAIN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, PRECISION, SCALE, TY
...
@@ -2674,7 +2677,7 @@ select DOMAIN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, PRECISION, SCALE, TY
script nodata nopasswords nosettings;
script nodata nopasswords nosettings;
> SCRIPT
> SCRIPT
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> -- 1 +/- SELECT COUNT(*) FROM PUBLIC.ADDRESS;
> -- 1 +/- SELECT COUNT(*) FROM PUBLIC.ADDRESS;
> -- 1 +/- SELECT COUNT(*) FROM PUBLIC.TEST;
> -- 1 +/- SELECT COUNT(*) FROM PUBLIC.TEST;
> ALTER TABLE PUBLIC.ADDRESS ADD CONSTRAINT PUBLIC.CONSTRAINT_E PRIMARY KEY(ID);
> ALTER TABLE PUBLIC.ADDRESS ADD CONSTRAINT PUBLIC.CONSTRAINT_E PRIMARY KEY(ID);
...
@@ -2685,8 +2688,8 @@ script nodata nopasswords nosettings;
...
@@ -2685,8 +2688,8 @@ script nodata nopasswords nosettings;
> CREATE DOMAIN STRING2 AS VARCHAR NOT NULL;
> CREATE DOMAIN STRING2 AS VARCHAR NOT NULL;
> CREATE DOMAIN STRING3 AS VARCHAR DEFAULT '
<
empty
>
';
> CREATE DOMAIN STRING3 AS VARCHAR DEFAULT '
<
empty
>
';
> CREATE DOMAIN STRING_X AS VARCHAR DEFAULT '
<
empty
>
';
> CREATE DOMAIN STRING_X AS VARCHAR DEFAULT '
<
empty
>
';
> CREATE MEMORY TABLE PUBLIC.ADDRESS( ID INT NOT NULL, NAME
VARCHAR(200) CHECK (POSITION('
@
', NAME) > 1), NAME2 VARCHAR(200)
DEFAULT '
@
gmail
.
com
' CHECK ((POSITION('
@
', NAME2) > 1) AND (POSITION('
gmail
', NAME2) > 1)) );
> CREATE MEMORY TABLE PUBLIC.ADDRESS( ID INT NOT NULL, NAME
EMAIL CHECK (POSITION('
@
', NAME) > 1), NAME2 GMAIL
DEFAULT '
@
gmail
.
com
' CHECK ((POSITION('
@
', NAME2) > 1) AND (POSITION('
gmail
', NAME2) > 1)) );
> CREATE MEMORY TABLE PUBLIC.TEST( A
VARCHAR(255) DEFAULT
''
NOT NULL, B VARCHAR, C VARCHAR NOT NULL, D VARCHAR
DEFAULT '
<
empty
>
' );
> CREATE MEMORY TABLE PUBLIC.TEST( A
STRING DEFAULT
''
NOT NULL, B STRING1, C STRING2 NOT NULL, D STRING3
DEFAULT '
<
empty
>
' );
> CREATE USER IF NOT EXISTS SA PASSWORD
''
ADMIN;
> CREATE USER IF NOT EXISTS SA PASSWORD
''
ADMIN;
> rows: 13
> rows: 13
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论