Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
dcfa73c2
Unverified
提交
dcfa73c2
authored
2月 28, 2018
作者:
Noel Grandin
提交者:
GitHub
2月 28, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #913 from katzyn/misc
Assorted changes in tests and documentation
上级
59288b3d
3a732dd3
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
101 行增加
和
49 行删除
+101
-49
help.csv
h2/src/docsrc/help/help.csv
+47
-37
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+2
-2
truncate.sql
...c/test/org/h2/test/scripts/functions/numeric/truncate.sql
+24
-0
truncate.sql
...st/org/h2/test/scripts/functions/timeanddate/truncate.sql
+28
-0
testSimple.in.txt
h2/src/test/org/h2/test/scripts/testSimple.in.txt
+0
-10
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
dcfa73c2
...
...
@@ -2018,8 +2018,9 @@ CALL CSVWRITE('test2.csv', 'SELECT * FROM TEST', 'charset=UTF-8 fieldSeparator=|
"Other Grammar","Data Type","
intType | booleanType | tinyintType | smallintType | bigintType | identityType
| decimalType | doubleType | realType | dateType | timeType | timestampType
| binaryType | otherType | varcharType | varcharIgnorecaseType | charType
| blobType | clobType | uuidType | arrayType | enumType
| timestampWithTimeZoneType | binaryType | otherType | varcharType
| varcharIgnorecaseType | charType | blobType | clobType | uuidType
| arrayType | enumType
","
A data type definition.
","
...
...
@@ -2330,8 +2331,16 @@ TIMESTAMP WITH TIME ZONE '2005-12-31 23:59:59.123+05'
TIMESTAMP WITH TIME ZONE '2005-12-31 23:59:59.123456789 Europe/London'
"
"Other Grammar","Date and time","
date | time | timestamp | timestampWithTimeZone
","
A literal value of any date-time data type.
","
TIMESTAMP '1999-01-31 10:00:00'
"
"Other Grammar","Value","
string | dollarQuotedString | numeric | date
| time | timestamp
| boolean | bytes | array | null
string | dollarQuotedString | numeric | date
AndTime
| boolean | bytes | array | null
","
A literal value of any data type, or null.
","
...
...
@@ -3194,7 +3203,8 @@ CALL HASH('SHA256', STRINGTOUTF8('Password'), 1000)
"
"Functions (Numeric)","TRUNCATE","
{ TRUNC | TRUNCATE } ( { {numeric, digitsInt} | timestamp | date | timestampString } )
{ TRUNC | TRUNCATE } ( { {numeric, digitsInt}
| timestamp | timestampWithTimeZone | date | timestampString } )
","
Truncates to a number of digits (to the next value closer to 0).
This method returns a double.
...
...
@@ -3652,7 +3662,7 @@ CALL TO_CHAR(TIMESTAMP '2010-01-01 00:00:00', 'DD MON, YYYY')
"
"Functions (String)","TRANSLATE","
TRANSLATE(value
, searchString, replacementString]]
)
TRANSLATE(value
, searchString, replacementString
)
","
Oracle-compatible TRANSLATE function that replaces a sequence of characters in a string with another set of characters.
","
...
...
@@ -3688,7 +3698,7 @@ CURRENT_TIMESTAMP()
"
"Functions (Time and Date)","DATEADD","
{ DATEADD| TIMESTAMPADD } (unitString, addIntLong,
timestamp
)
{ DATEADD| TIMESTAMPADD } (unitString, addIntLong,
dateAndTime
)
","
Adds units to a date-time value. The string indicates the unit.
Use negative values to subtract units.
...
...
@@ -3704,20 +3714,20 @@ DATEADD('MONTH', 1, DATE '2001-01-31')
"
"Functions (Time and Date)","DATEDIFF","
{ DATEDIFF | TIMESTAMPDIFF } (unitString, a
Timestamp, bTimestamp
)
{ DATEDIFF | TIMESTAMPDIFF } (unitString, a
DateAndTime, bDateAndTime
)
","
Returns the the number of crossed unit boundaries between two
timestamp
s.
Returns the the number of crossed unit boundaries between two
date/time value
s.
This method returns a long.
The string indicates the unit.
The same units as in the EXTRACT function are supported.
Only TIMEZONE_HOUR and TIMEZONE_MINUTE units use the time zone offset component.
With all other units if
timestamp
s have time zone offset component it is ignored.
With all other units if
date/time value
s have time zone offset component it is ignored.
","
DATEDIFF('YEAR', T1.CREATED, T2.CREATED)
"
"Functions (Time and Date)","DAYNAME","
DAYNAME(date)
DAYNAME(date
AndTime
)
","
Returns the name of the day (in English).
","
...
...
@@ -3725,7 +3735,7 @@ DAYNAME(CREATED)
"
"Functions (Time and Date)","DAY_OF_MONTH","
DAY_OF_MONTH(date)
DAY_OF_MONTH(date
AndTime
)
","
Returns the day of the month (1-31).
","
...
...
@@ -3733,7 +3743,7 @@ DAY_OF_MONTH(CREATED)
"
"Functions (Time and Date)","DAY_OF_WEEK","
DAY_OF_WEEK(date)
DAY_OF_WEEK(date
AndTime
)
","
Returns the day of the week (1 means Sunday).
","
...
...
@@ -3741,7 +3751,7 @@ DAY_OF_WEEK(CREATED)
"
"Functions (Time and Date)","DAY_OF_YEAR","
DAY_OF_YEAR(date)
DAY_OF_YEAR(date
AndTime
)
","
Returns the day of the year (1-366).
","
...
...
@@ -3754,9 +3764,9 @@ EXTRACT ( { YEAR | YY | MONTH | MM | QUARTER | WEEK | ISO_WEEK
| HOUR | HH | MINUTE | MI | SECOND | SS | EPOCH
| MILLISECOND | MS | MICROSECOND | MCS | NANOSECOND | NS
| TIMEZONE_HOUR | TIMEZONE_MINUTE }
FROM
timestamp
)
FROM
dateAndTime
)
","
Returns a
specific value from a timestamps
.
Returns a
value of the specific time unit from a date/time value
.
This method returns a numeric value with EPOCH unit and
an int for all other time units.
","
...
...
@@ -3764,15 +3774,15 @@ EXTRACT(SECOND FROM CURRENT_TIMESTAMP)
"
"Functions (Time and Date)","FORMATDATETIME","
FORMATDATETIME (
timestamp
, formatString
FORMATDATETIME (
dateAndTime
, formatString
[ , localeString [ , timeZoneString ] ] )
","
Formats a date, time or timestamp as a string.
The most important format characters are:
y year, M month, d day, H hour, m minute, s second.
For details of the format, see ""java.text.SimpleDateFormat"".
timeZoneString may be specified if
timestamp
is a DATE, TIME or TIMESTAMP.
timeZoneString is ignored if
timestamp
is TIMESTAMP WITH TIME ZONE.
timeZoneString may be specified if
dateAndTime
is a DATE, TIME or TIMESTAMP.
timeZoneString is ignored if
dateAndTime
is TIMESTAMP WITH TIME ZONE.
This method returns a string.
","
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06',
...
...
@@ -3780,31 +3790,31 @@ CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06',
"
"Functions (Time and Date)","HOUR","
HOUR(
timestamp
)
HOUR(
dateAndTime
)
","
Returns the hour (0-23) from a
timestamp
.
Returns the hour (0-23) from a
date/time value
.
","
HOUR(CREATED)
"
"Functions (Time and Date)","MINUTE","
MINUTE(
timestamp
)
MINUTE(
dateAndTime
)
","
Returns the minute (0-59) from a
timestamp
.
Returns the minute (0-59) from a
date/time value
.
","
MINUTE(CREATED)
"
"Functions (Time and Date)","MONTH","
MONTH(
timestamp
)
MONTH(
dateAndTime
)
","
Returns the month (1-12) from a
timestamp
.
Returns the month (1-12) from a
date/time value
.
","
MONTH(CREATED)
"
"Functions (Time and Date)","MONTHNAME","
MONTHNAME(date)
MONTHNAME(date
AndTime
)
","
Returns the name of the month (in English).
","
...
...
@@ -3825,34 +3835,34 @@ CALL PARSEDATETIME('Sat, 3 Feb 2001 03:05:06 GMT',
"
"Functions (Time and Date)","QUARTER","
QUARTER(
timestamp
)
QUARTER(
dateAndTime
)
","
Returns the quarter (1-4) from a
timestamp
.
Returns the quarter (1-4) from a
date/time value
.
","
QUARTER(CREATED)
"
"Functions (Time and Date)","SECOND","
SECOND(
timestamp
)
SECOND(
dateAndTime
)
","
Returns the second (0-59) from a
timestamp
.
Returns the second (0-59) from a
date/time value
.
","
SECOND(CREATED)
"
"Functions (Time and Date)","WEEK","
WEEK(
timestamp
)
WEEK(
dateAndTime
)
","
Returns the week (1-53) from a
timestamp
.
Returns the week (1-53) from a
date/time value
.
This method uses the current system locale.
","
WEEK(CREATED)
"
"Functions (Time and Date)","ISO_WEEK","
ISO_WEEK(
timestamp
)
ISO_WEEK(
dateAndTime
)
","
Returns the ISO week (1-53) from a
timestamp
.
Returns the ISO week (1-53) from a
date/time value
.
This method uses the ISO definition when
first week of year should have at least four days
and week is started with Monday.
...
...
@@ -3861,17 +3871,17 @@ ISO_WEEK(CREATED)
"
"Functions (Time and Date)","YEAR","
YEAR(
timestamp
)
YEAR(
dateAndTime
)
","
Returns the year from a
timestamp
.
Returns the year from a
date/time value
.
","
YEAR(CREATED)
"
"Functions (Time and Date)","ISO_YEAR","
ISO_YEAR(
timestamp
)
ISO_YEAR(
dateAndTime
)
","
Returns the ISO week year from a
timestamp
.
Returns the ISO week year from a
date/time value
.
","
ISO_YEAR(CREATED)
"
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
dcfa73c2
...
...
@@ -117,7 +117,7 @@ public class TestScript extends TestBase {
"expand"
,
"floor"
,
"hash"
,
"length"
,
"log"
,
"mod"
,
"pi"
,
"power"
,
"radians"
,
"rand"
,
"random-uuid"
,
"round"
,
"roundmagic"
,
"secure-rand"
,
"sign"
,
"sin"
,
"sinh"
,
"sqrt"
,
"tan"
,
"tanh"
,
"trunc
"
,
"trunc
ate"
,
"zero"
})
{
"tan"
,
"tanh"
,
"truncate"
,
"zero"
})
{
testScript
(
"functions/numeric/"
+
s
+
".sql"
);
}
for
(
String
s
:
new
String
[]
{
"ascii"
,
"bit-length"
,
"char"
,
"concat"
,
...
...
@@ -146,7 +146,7 @@ public class TestScript extends TestBase {
"current-time"
,
"dateadd"
,
"datediff"
,
"dayname"
,
"day-of-month"
,
"day-of-week"
,
"day-of-year"
,
"extract"
,
"formatdatetime"
,
"hour"
,
"minute"
,
"month"
,
"monthname"
,
"parsedatetime"
,
"quarter"
,
"second"
,
"week"
,
"year"
})
{
"parsedatetime"
,
"quarter"
,
"second"
,
"
truncate"
,
"
week"
,
"year"
})
{
testScript
(
"functions/timeanddate/"
+
s
+
".sql"
);
}
deleteDb
(
"script"
);
...
...
h2/src/test/org/h2/test/scripts/functions/numeric/truncate.sql
浏览文件 @
dcfa73c2
...
...
@@ -2,3 +2,27 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
create
memory
table
test
(
id
int
primary
key
,
name
varchar
(
255
));
>
ok
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
truncate
(
null
,
null
)
en
,
truncate
(
1
.
99
,
0
)
e1
,
truncate
(
-
10
.
9
,
0
)
em10
from
test
;
>
EN
E1
EM10
>
---- --- -----
>
null
1
.
0
-
10
.
0
>
rows
:
1
select
trunc
(
null
,
null
)
en
,
trunc
(
1
.
99
,
0
)
e1
,
trunc
(
-
10
.
9
,
0
)
em10
from
test
;
>
EN
E1
EM10
>
---- --- -----
>
null
1
.
0
-
10
.
0
>
rows
:
1
select
trunc
(
1
.
3
)
R
;
>
R
>
---
>
1
.
0
>
rows
:
1
h2/src/test/org/h2/test/scripts/functions/
numeric/trunc
.sql
→
h2/src/test/org/h2/test/scripts/functions/
timeanddate/truncate
.sql
浏览文件 @
dcfa73c2
...
...
@@ -3,24 +3,26 @@
-- Initial Developer: H2 Group
--
create
memory
table
test
(
id
int
primary
key
,
name
varchar
(
255
));
>
ok
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
truncate
(
null
,
null
)
en
,
truncate
(
1
.
99
,
0
)
e1
,
truncate
(
-
10
.
9
,
0
)
em10
from
test
;
>
EN
E1
EM10
>
---- --- -----
>
null
1
.
0
-
10
.
0
select
trunc
(
'2015-05-29 15:00:00'
)
R
;
>
R
>
---------------------
>
2015
-
05
-
29
00
:
00
:
00
.
0
>
rows
:
1
select
trunc
(
null
,
null
)
en
,
trunc
(
1
.
99
,
0
)
e1
,
trunc
(
-
10
.
9
,
0
)
em10
from
test
;
>
EN
E1
EM10
>
----
---
-----
>
null
1
.
0
-
1
0
.
0
select
trunc
(
'2015-05-29'
)
R
;
>
R
>
----
------------
-----
>
2015
-
05
-
29
00
:
00
:
0
0
.
0
>
rows
:
1
select
trunc
(
timestamp
'2000-01-01 10:20:30.0'
)
R
;
>
R
>
---------------------
>
2000
-
01
-
01
00
:
00
:
00
.
0
>
rows
:
1
select
trunc
(
timestamp
'2001-01-01 14:00:00.0'
)
R
;
>
R
>
---------------------
>
2001
-
01
-
01
00
:
00
:
00
.
0
>
rows
:
1
h2/src/test/org/h2/test/scripts/testSimple.in.txt
浏览文件 @
dcfa73c2
select trunc('2015-05-29 15:00:00');
> 2015-05-29 00:00:00.0;
select trunc('2015-05-29');
> 2015-05-29 00:00:00.0;
select trunc(timestamp '2000-01-01 10:20:30.0');
> 2000-01-01 00:00:00.0;
select 1000L / 10;
> 100;
select * from (select x as y from dual order by y);
> 1;
select a.x from dual a, dual b order by x;
> 1;
select trunc(1.3);
> 1.0;
select trunc(timestamp '2001-01-01 14:00:00.0');
> 2001-01-01 00:00:00.0;
select 1 from(select 2 from(select 1) a right join dual b) c;
> 1;
select 1.00 / 3 * 0.00;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论