Unverified 提交 5e78f932 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #939 from katzyn/tests

Short syntax for SQL tests
......@@ -389,6 +389,26 @@ public class TestScript extends TestBase {
head[i] = label;
}
rs.close();
String line = readLine();
putBack = line;
if (line != null && line.startsWith(">> ")) {
switch (result.size()) {
case 0:
writeResult(sql, "<no result>", null, ">> ");
return;
case 1:
String[] row = result.get(0);
if (row.length == 1) {
writeResult(sql, row[0], null, ">> ");
} else {
writeResult(sql, "<row with " + row.length + " values>", null, ">> ");
}
return;
default:
writeResult(sql, "<" + result.size() + " rows>", null, ">> ");
return;
}
}
writeResult(sql, format(head, max), null);
writeResult(sql, format(null, max), null);
String[] array = new String[result.size()];
......@@ -433,10 +453,13 @@ public class TestScript extends TestBase {
writeResult(sql, "exception", e);
}
private void writeResult(String sql, String s, SQLException e)
throws Exception {
private void writeResult(String sql, String s, SQLException e) throws Exception {
writeResult(sql, s, e, "> ");
}
private void writeResult(String sql, String s, SQLException e, String prefix) throws Exception {
assertKnownException(sql, e);
s = ("> " + s).trim();
s = (prefix + s).trim();
String compare = readLine();
if (compare != null && compare.startsWith(">")) {
if (!compare.equals(s)) {
......
......@@ -80,9 +80,7 @@ INSERT INTO TEST(T0) VALUES ('23:59:59.999999999');
> update count: 1
SELECT T0 FROM TEST;
> T0
> ------------------
> 23:59:59.999999999
>> 23:59:59.999999999
DROP TABLE TEST;
> ok
......@@ -91,9 +91,7 @@ INSERT INTO TEST(T0) VALUES ('2000-01-01 23:59:59.999999999Z');
> update count: 1
SELECT T0 FROM TEST;
> T0
> ----------------------
> 2000-01-02 00:00:00+00
>> 2000-01-02 00:00:00+00
DROP TABLE TEST;
> ok
......@@ -41,10 +41,7 @@ INSERT INTO TEST VALUES (TIMESTAMP '1999-12-31 08:00:00');
> update count: 1
SELECT TIMESTAMP FROM TEST;
> TIMESTAMP
> -------------------
> 1999-12-31 08:00:00
> rows: 1
>> 1999-12-31 08:00:00
DROP TABLE TEST;
> ok
......@@ -84,9 +81,7 @@ INSERT INTO TEST(T0) VALUES ('2000-01-01 23:59:59.999999999');
> update count: 1
SELECT T0 FROM TEST;
> T0
> -------------------
> 2000-01-02 00:00:00
>> 2000-01-02 00:00:00
DROP TABLE TEST;
> ok
......@@ -15,11 +15,8 @@ select abs(-1) r1, abs(id) r1b from test;
> 1 1
> rows: 1
select abs(sum(id)) r1 from test;
> R1
> --
> 1
> rows: 1
select abs(sum(id)) from test;
>> 1
select abs(null) vn, abs(-1) r1, abs(1) r2, abs(0) r3, abs(-0.1) r4, abs(0.1) r5 from test;
> VN R1 R2 R3 R4 R5
......
......@@ -4,14 +4,7 @@
--
call utf8tostring(decrypt('AES', '00000000000000000000000000000000', 'dbd42d55d4b923c4b03eba0396fac98e'));
> 'Hello World Test'
> ------------------
> Hello World Test
> rows: 1
>> Hello World Test
call utf8tostring(decrypt('AES', hash('sha256', stringtoutf8('Hello'), 1000), encrypt('AES', hash('sha256', stringtoutf8('Hello'), 1000), stringtoutf8('Hello World Test'))));
> 'Hello World Test'
> ------------------
> Hello World Test
> rows: 1
>> Hello World Test
......@@ -4,20 +4,10 @@
--
call encrypt('AES', '00000000000000000000000000000000', stringtoutf8('Hello World Test'));
> X'dbd42d55d4b923c4b03eba0396fac98e'
> -----------------------------------
> dbd42d55d4b923c4b03eba0396fac98e
> rows: 1
>> dbd42d55d4b923c4b03eba0396fac98e
CALL ENCRYPT('XTEA', '00', STRINGTOUTF8('Test'));
> X'8bc9a4601b3062692a72a5941072425f'
> -----------------------------------
> 8bc9a4601b3062692a72a5941072425f
> rows: 1
>> 8bc9a4601b3062692a72a5941072425f
call encrypt('XTEA', '000102030405060708090a0b0c0d0e0f', '4142434445464748');
> X'dea0b0b40966b0669fbae58ab503765f'
> -----------------------------------
> dea0b0b40966b0669fbae58ab503765f
> rows: 1
>> dea0b0b40966b0669fbae58ab503765f
......@@ -4,13 +4,7 @@
--
call hash('SHA256', stringtoutf8('Hello'), 1);
> X'185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969'
> -------------------------------------------------------------------
> 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
> rows: 1
>> 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
CALL HASH('SHA256', STRINGTOUTF8('Password'), 1000);
> X'c644a176ce920bde361ac336089b06cc2f1514dfa95ba5aabfe33f9a22d577f0'
> -------------------------------------------------------------------
> c644a176ce920bde361ac336089b06cc2f1514dfa95ba5aabfe33f9a22d577f0
> rows: 1
>> c644a176ce920bde361ac336089b06cc2f1514dfa95ba5aabfe33f9a22d577f0
......@@ -9,11 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select pi() pi from test;
> PI
> -----------------
> 3.141592653589793
> rows: 1
select pi() from test;
>> 3.141592653589793
......@@ -15,12 +15,5 @@ select rand(1) e, random() f from test;
> 0.7308781907032909 0.41008081149220166
> rows: 1
select rand() e from test;
> E
> -------------------
> 0.20771484130971707
> rows: 1
select rand() from test;
>> 0.20771484130971707
......@@ -21,8 +21,5 @@ select trunc(null, null) en, trunc(1.99, 0) e1, trunc(-10.9, 0) em10 from test;
> null 1.0 -10.0
> rows: 1
select trunc(1.3) R;
> R
> ---
> 1.0
> rows: 1
select trunc(1.3);
>> 1.0
......@@ -13,10 +13,5 @@ select concat(null, null) en, concat(null, 'a') ea, concat('b', null) eb, concat
> null a b abc
> rows: 1
SELECT CONCAT('a', 'b', 'c', 'd') AS test;
> TEST
> ----
> abcd
> rows: 1
SELECT CONCAT('a', 'b', 'c', 'd');
>> abcd
......@@ -2,3 +2,6 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
select lpad('string', 10, '+');
>> ++++string
......@@ -7,53 +7,29 @@ call regexp_replace('x', 'x', '\');
> exception
CALL REGEXP_REPLACE('abckaboooom', 'o+', 'o');
> 'abckabom'
> ----------
> abckabom
> rows: 1
>> abckabom
select regexp_replace('Sylvain', 'S..', 'TOTO', 'mni') as X;
> X
> --------
> TOTOvain
> rows: 1
select regexp_replace('Sylvain', 'S..', 'TOTO', 'mni');
>> TOTOvain
set mode oracle;
select regexp_replace('first last', '(\w+) (\w+)', '\2 \1') as X from dual;
> X
> ----------
> last first
> rows: 1
select regexp_replace('first last', '(\w+) (\w+)', '\\2 \1') as X from dual;
> X
> --------
> \2 first
> rows: 1
select regexp_replace('first last', '(\w+) (\w+)', '\$2 \1') as X from dual;
> X
> --------
> $2 first
> rows: 1
select regexp_replace('first last', '(\w+) (\w+)', '$2 $1') as X from dual;
> X
> -----
> $2 $1
> rows: 1
select regexp_replace('first last', '(\w+) (\w+)', '\2 \1');
>> last first
select regexp_replace('first last', '(\w+) (\w+)', '\\2 \1');
>> \2 first
select regexp_replace('first last', '(\w+) (\w+)', '\$2 \1');
>> $2 first
select regexp_replace('first last', '(\w+) (\w+)', '$2 $1');
>> $2 $1
set mode regular;
select regexp_replace('first last', '(\w+) (\w+)', '\2 \1') as X from dual;
> X
> ---
> 2 1
> rows: 1
select regexp_replace('first last', '(\w+) (\w+)', '$2 $1') as X from dual;
> X
> ----------
> last first
> rows: 1
select regexp_replace('first last', '(\w+) (\w+)', '\2 \1');
>> 2 1
select regexp_replace('first last', '(\w+) (\w+)', '$2 $1');
>> last first
......@@ -7,10 +7,7 @@ call select 1 from dual where regexp_like('x', 'x', '\');
> exception
select x from dual where REGEXP_LIKE('A', '[a-z]', 'i');
> X
> -
> 1
> rows: 1
>> 1
select x from dual where REGEXP_LIKE('A', '[a-z]', 'c');
> X
......
......@@ -2,3 +2,6 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
select rpad('string', 10, '+');
>> string++++
......@@ -10,15 +10,7 @@ INSERT INTO TEST VALUES(2, STRINGDECODE('abcsond\344rzeich\344 ') || char(22222)
> update count: 1
call STRINGENCODE(STRINGDECODE('abcsond\344rzeich\344 \u56ce \366\344\374\326\304\334\351\350\340\361!'));
> 'abcsond\u00e4rzeich\u00e4 \u56ce \u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e9\u00e8\u00e0\u00f1!'
> ------------------------------------------------------------------------------------------------
> abcsond\u00e4rzeich\u00e4 \u56ce \u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e9\u00e8\u00e0\u00f1!
> rows: 1
>> abcsond\u00e4rzeich\u00e4 \u56ce \u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e9\u00e8\u00e0\u00f1!
CALL STRINGENCODE(STRINGDECODE('Lines 1\nLine 2'));
> 'Lines 1\nLine 2'
> -----------------
> Lines 1\nLine 2
> rows: 1
>> Lines 1\nLine 2
......@@ -26,3 +26,9 @@ select substring(null from null) en, substring(null from null for null) e1, subs
> ---- ---- ---- --
> null null ob o
> rows: 1
select substr('[Hello]', 2, 5);
>> Hello
select substr('Hello World', -5);
>> World
......@@ -4,8 +4,4 @@
--
CALL UTF8TOSTRING(STRINGTOUTF8('This is a test'));
> 'This is a test'
> ----------------
> This is a test
> rows: 1
>> This is a test
......@@ -4,14 +4,7 @@
--
CALL XMLCDATA('<characters>');
> '<![CDATA[<characters>]]>'
> --------------------------
> <![CDATA[<characters>]]>
> rows: 1
>> <![CDATA[<characters>]]>
CALL XMLCDATA('special text ]]>');
> 'special text ]]&gt;'
> ---------------------
> special text ]]&gt;
> rows: 1
>> special text ]]&gt;
......@@ -4,14 +4,7 @@
--
CALL XMLCOMMENT('Test');
> STRINGDECODE('<!-- Test -->\n')
> -------------------------------
> <!-- Test -->
> rows: 1
>> <!-- Test -->
CALL XMLCOMMENT('--- test ---');
> STRINGDECODE('<!-- - - - test - - - -->\n')
> -------------------------------------------
> <!-- - - - test - - - -->
> rows: 1
>> <!-- - - - test - - - -->
......@@ -4,32 +4,16 @@
--
CALL XMLNODE('a', XMLATTR('href', 'http://h2database.com'));
> STRINGDECODE('<a href=\"http://h2database.com\"/>\n')
> -----------------------------------------------------
> <a href="http://h2database.com"/>
> rows: 1
>> <a href="http://h2database.com"/>
CALL XMLNODE('br');
> STRINGDECODE('<br/>\n')
> -----------------------
> <br/>
> rows: 1
>> <br/>
CALL XMLNODE('p', null, 'Hello World');
> STRINGDECODE('<p>Hello World</p>\n')
> ------------------------------------
> <p>Hello World</p>
> rows: 1
>> <p>Hello World</p>
SELECT XMLNODE('p', null, 'Hello' || chr(10) || 'World') X;
> X
> ---------------------
> <p> Hello World </p>
> rows: 1
SELECT XMLNODE('p', null, 'Hello' || chr(10) || 'World', false) X;
> X
> -------------------
> <p>Hello World</p>
> rows: 1
SELECT XMLNODE('p', null, 'Hello' || chr(10) || 'World');
>> <p> Hello World </p>
SELECT XMLNODE('p', null, 'Hello' || chr(10) || 'World', false);
>> <p>Hello World</p>
......@@ -4,8 +4,4 @@
--
CALL XMLSTARTDOC();
> STRINGDECODE('<?xml version=\"1.0\"?>\n')
> -----------------------------------------
> <?xml version="1.0"?>
> rows: 1
>> <?xml version="1.0"?>
......@@ -4,26 +4,13 @@
--
CALL XMLTEXT('test');
> 'test'
> ------
> test
> rows: 1
>> test
CALL XMLTEXT('<test>');
> '&lt;test&gt;'
> --------------
> &lt;test&gt;
> rows: 1
>> &lt;test&gt;
SELECT XMLTEXT('hello' || chr(10) || 'world') X;
> X
> -----------
> hello world
> rows: 1
SELECT XMLTEXT('hello' || chr(10) || 'world');
>> hello world
CALL XMLTEXT('hello' || chr(10) || 'world', true);
> 'hello&#xa;world'
> -----------------
> hello&#xa;world
> rows: 1
>> hello&#xa;world
......@@ -2,3 +2,30 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
select array_contains((4.0, 2.0, 2.0), 2.0);
>> TRUE
select array_contains((4.0, 2.0, 2.0), 5.0);
>> FALSE
select array_contains(('one', 'two'), 'one');
>> TRUE
select array_contains(('one', 'two'), 'xxx');
>> FALSE
select array_contains(('one', 'two'), null);
>> FALSE
select array_contains((null, 'two'), null);
>> TRUE
select array_contains(null, 'one');
>> FALSE
select array_contains(((1, 2), (3, 4)), (1, 2));
>> TRUE
select array_contains(((1, 2), (3, 4)), (5, 6));
>> FALSE
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select autocommit() x_true from test;
> X_TRUE
> ------
> TRUE
> rows: 1
select autocommit() from test;
>> TRUE
......@@ -15,3 +15,75 @@ select cast(null as varchar(255)) xn, cast(' 10' as int) x10, cast(' 20 ' as int
> ---- --- ---
> null 10 20
> rows: 1
select cast(128 as binary);
>> 00000080
select cast(65535 as binary);
>> 0000ffff
select cast(cast('ff' as binary) as tinyint) x;
>> -1
select cast(cast('7f' as binary) as tinyint) x;
>> 127
select cast(cast('ff' as binary) as smallint) x;
>> 255
select cast(cast('ff' as binary) as int) x;
>> 255
select cast(cast('ffff' as binary) as long) x;
>> 65535
select cast(cast(65535 as long) as binary);
>> 000000000000ffff
select cast(cast(-1 as tinyint) as binary);
>> ff
select cast(cast(-1 as smallint) as binary);
>> ffff
select cast(cast(-1 as int) as binary);
>> ffffffff
select cast(cast(-1 as long) as binary);
>> ffffffffffffffff
select cast(cast(1 as tinyint) as binary);
>> 01
select cast(cast(1 as smallint) as binary);
>> 0001
select cast(cast(1 as int) as binary);
>> 00000001
select cast(cast(1 as long) as binary);
>> 0000000000000001
select cast(X'ff' as tinyint);
>> -1
select cast(X'ffff' as smallint);
>> -1
select cast(X'ffffffff' as int);
>> -1
select cast(X'ffffffffffffffff' as long);
>> -1
select cast(' 011 ' as int);
>> 11
select cast(cast(0.1 as real) as decimal);
>> 0.1
select cast(cast(95605327.73 as float) as decimal);
>> 95605327.73
select cast(cast('01020304-0506-0708-090a-0b0c0d0e0f00' as uuid) as binary);
>> 0102030405060708090a0b0c0d0e0f00
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select right(database(), 6) x_script from test;
> X_SCRIPT
> --------
> SCRIPT
> rows: 1
select right(database(), 6) from test;
>> SCRIPT
......@@ -2,3 +2,27 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
select select decode(null, null, 'a');
>> a
select select decode(1, 1, 'a');
>> a
select select decode(1, 2, 'a');
>> null
select select decode(1, 1, 'a', 'else');
>> a
select select decode(1, 2, 'a', 'else');
>> else
select decode(4.0, 2.0, 2.0, 3.0, 3.0);
>> null
select decode('3', 2.0, 2.0, 3, 3.0);
>> 3.0
select decode(4.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 9.0);
>> 4.0
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select readonly() x_false from test;
> X_FALSE
> -------
> FALSE
> rows: 1
select readonly() from test;
>> FALSE
......@@ -15,8 +15,5 @@ select user() x_sa, current_user() x_sa2 from test;
> SA SA
> rows: 1
select current_user() x_sa from test;
> X_SA
> ----
> SA
> rows: 1
select current_user() from test;
>> SA
......@@ -4,29 +4,17 @@
--
-- 01-Aug-03 + 3 months = 01-Nov-03
SELECT ADD_MONTHS('2003-08-01', 3) AS R;
> R
> -------------------
> 2003-11-01 00:00:00
> rows: 1
SELECT ADD_MONTHS('2003-08-01', 3);
>> 2003-11-01 00:00:00
-- 31-Jan-03 + 1 month = 28-Feb-2003
SELECT ADD_MONTHS('2003-01-31', 1) AS R;
> R
> -------------------
> 2003-02-28 00:00:00
> rows: 1
SELECT ADD_MONTHS('2003-01-31', 1);
>> 2003-02-28 00:00:00
-- 21-Aug-2003 - 3 months = 21-May-2003
SELECT ADD_MONTHS('2003-08-21', -3) AS R;
> R
> -------------------
> 2003-05-21 00:00:00
> rows: 1
SELECT ADD_MONTHS('2003-08-21', -3);
>> 2003-05-21 00:00:00
-- 21-Aug-2003 00:00:00.333 - 3 months = 21-May-2003 00:00:00.333
SELECT ADD_MONTHS('2003-08-21 00:00:00.333', -3) AS R;
> R
> -----------------------
> 2003-05-21 00:00:00.333
> rows: 1
SELECT ADD_MONTHS('2003-08-21 00:00:00.333', -3);
>> 2003-05-21 00:00:00.333
......@@ -9,17 +9,11 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select dateadd('month', 1, timestamp '2003-01-31 10:20:30.012345678') d1 from test;
> D1
> -----------------------------
> 2003-02-28 10:20:30.012345678
> rows: 1
select dateadd('month', 1, timestamp '2003-01-31 10:20:30.012345678') from test;
>> 2003-02-28 10:20:30.012345678
select dateadd('year', -1, timestamp '2000-02-29 10:20:30.012345678') d1 from test;
> D1
> -----------------------------
> 1999-02-28 10:20:30.012345678
> rows: 1
select dateadd('year', -1, timestamp '2000-02-29 10:20:30.012345678') from test;
>> 1999-02-28 10:20:30.012345678
drop table test;
> ok
......@@ -30,47 +24,26 @@ create table test(d date, t time, ts timestamp);
insert into test values(date '2001-01-01', time '01:00:00', timestamp '2010-01-01 00:00:00');
> update count: 1
select ts + t x from test;
> X
> -------------------
> 2010-01-01 01:00:00
> rows: 1
select ts + t from test;
>> 2010-01-01 01:00:00
select ts + t + t - t x from test;
> X
> -------------------
> 2010-01-01 01:00:00
> rows: 1
>> 2010-01-01 01:00:00
select ts + t * 0.5 x from test;
> X
> -------------------
> 2010-01-01 00:30:00
> rows: 1
>> 2010-01-01 00:30:00
select ts + 0.5 x from test;
> X
> -------------------
> 2010-01-01 12:00:00
> rows: 1
>> 2010-01-01 12:00:00
select ts - 1.5 x from test;
> X
> -------------------
> 2009-12-30 12:00:00
> rows: 1
>> 2009-12-30 12:00:00
select ts + 0.5 * t + t - t x from test;
> X
> -------------------
> 2010-01-01 00:30:00
> rows: 1
>> 2010-01-01 00:30:00
select ts + t / 0.5 x from test;
> X
> -------------------
> 2010-01-01 02:00:00
> rows: 1
>> 2010-01-01 02:00:00
select d + t, t + d - t x from test;
> T + D X
......@@ -85,25 +58,16 @@ select 1 + d + 1, d - 1, 2 + ts + 2, ts - 2 from test;
> rows: 1
select 1 + d + t + 1 from test;
> DATEADD('DAY', 1, (T + DATEADD('DAY', 1, D)))
> ---------------------------------------------
> 2001-01-03 01:00:00
> rows: 1
>> 2001-01-03 01:00:00
select ts - t - 2 from test;
> DATEADD('DAY', -2, (TS - T))
> ----------------------------
> 2009-12-29 23:00:00
> rows: 1
>> 2009-12-29 23:00:00
drop table test;
> ok
call dateadd('MS', 1, TIMESTAMP '2001-02-03 04:05:06.789001');
> TIMESTAMP '2001-02-03 04:05:06.790001'
> --------------------------------------
> 2001-02-03 04:05:06.790001
> rows: 1
>> 2001-02-03 04:05:06.790001
SELECT DATEADD('MICROSECOND', 1, TIME '10:00:01'), DATEADD('MCS', 1, TIMESTAMP '2010-10-20 10:00:01.1');
> TIME '10:00:01.000001' TIMESTAMP '2010-10-20 10:00:01.100001'
......@@ -118,52 +82,29 @@ SELECT DATEADD('NANOSECOND', 1, TIME '10:00:01'), DATEADD('NS', 1, TIMESTAMP '20
> rows: 1
SELECT DATEADD('HOUR', 1, DATE '2010-01-20');
> TIMESTAMP '2010-01-20 01:00:00'
> -------------------------------
> 2010-01-20 01:00:00
> rows: 1
>> 2010-01-20 01:00:00
SELECT DATEADD('MINUTE', 30, TIME '12:30:55');
> TIME '13:00:55'
> ---------------
> 13:00:55
> rows: 1
>> 13:00:55
SELECT DATEADD('DAY', 1, TIME '12:30:55');
> exception
SELECT DATEADD('QUARTER', 1, DATE '2010-11-16');
> DATE '2011-02-16'
> -----------------
> 2011-02-16
> rows: 1
>> 2011-02-16
SELECT DATEADD('DAY', 10, TIMESTAMP WITH TIME ZONE '2000-01-05 15:00:30.123456789-10');
> TIMESTAMP WITH TIME ZONE '2000-01-15 15:00:30.123456789-10'
> -----------------------------------------------------------
> 2000-01-15 15:00:30.123456789-10
> rows: 1
>> 2000-01-15 15:00:30.123456789-10
SELECT TIMESTAMPADD('DAY', 10, TIMESTAMP '2000-01-05 15:00:30.123456789');
> TIMESTAMP '2000-01-15 15:00:30.123456789'
> -----------------------------------------
> 2000-01-15 15:00:30.123456789
> rows: 1
>> 2000-01-15 15:00:30.123456789
SELECT TIMESTAMPADD('TIMEZONE_HOUR', 1, TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+07:30') AS T;
> T
> -------------------------
> 2010-01-01 10:00:00+08:30
> rows: 1
SELECT TIMESTAMPADD('TIMEZONE_HOUR', 1, TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+07:30');
>> 2010-01-01 10:00:00+08:30
SELECT TIMESTAMPADD('TIMEZONE_MINUTE', -45, TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+07:30') AS T;
> T
> -------------------------
> 2010-01-01 10:00:00+06:45
> rows: 1
SELECT TIMESTAMPADD('TIMEZONE_MINUTE', -45, TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+07:30');
>> 2010-01-01 10:00:00+06:45
SELECT DATEADD(HOUR, 1, TIME '23:00:00') AS T;
> T
> --------
> 00:00:00
SELECT DATEADD(HOUR, 1, TIME '23:00:00');
>> 00:00:00
> rows: 1
......@@ -9,89 +9,47 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select datediff('yy', timestamp '2003-12-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('yy', timestamp '2003-12-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') from test;
>> 1
select datediff('year', timestamp '2003-12-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('year', timestamp '2003-12-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') from test;
>> 1
select datediff('mm', timestamp '2003-11-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d2 from test;
> D2
> --
> 2
> rows: 1
select datediff('mm', timestamp '2003-11-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') from test;
>> 2
select datediff('month', timestamp '2003-11-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d2 from test;
> D2
> --
> 2
> rows: 1
select datediff('month', timestamp '2003-11-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') from test;
>> 2
select datediff('dd', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-05 10:00:00.0') d4 from test;
> D4
> --
> 4
> rows: 1
select datediff('dd', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-05 10:00:00.0') from test;
>> 4
select datediff('day', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-05 10:00:00.0') d4 from test;
> D4
> --
> 4
> rows: 1
select datediff('day', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-05 10:00:00.0') from test;
>> 4
select datediff('hh', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-02 10:00:00.0') d24 from test;
> D24
> ---
> 24
> rows: 1
select datediff('hh', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-02 10:00:00.0') from test;
>> 24
select datediff('hour', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-02 10:00:00.0') d24 from test;
> D24
> ---
> 24
> rows: 1
select datediff('hour', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-02 10:00:00.0') from test;
>> 24
select datediff('mi', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d20 from test;
> D20
> ---
> -20
> rows: 1
select datediff('mi', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') from test;
>> -20
select datediff('minute', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d20 from test;
> D20
> ---
> -20
> rows: 1
select datediff('minute', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') from test;
>> -20
select datediff('ss', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('ss', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') from test;
>> 1
select datediff('second', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('second', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') from test;
>> 1
select datediff('ms', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d50x from test;
> D50X
> ----
> 500
> rows: 1
select datediff('ms', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') from test;
>> 500
select datediff('millisecond', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d50x from test;
> D50X
> ----
> 500
> rows: 1
select datediff('millisecond', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') from test;
>> 500
SELECT DATEDIFF('SECOND', '1900-01-01 00:00:00.001', '1900-01-01 00:00:00.002'), DATEDIFF('SECOND', '2000-01-01 00:00:00.001', '2000-01-01 00:00:00.002');
> 0 0
......@@ -154,10 +112,7 @@ call datediff('MS', TIMESTAMP '2001-02-03 04:05:06.789001', TIMESTAMP '2001-02-0
> rows: 1
call datediff('MS', TIMESTAMP '1900-01-01 00:00:01.000', TIMESTAMP '2008-01-01 00:00:00.000');
> 3408134399000
> -------------
> 3408134399000
> rows: 1
>> 3408134399000
SELECT DATEDIFF('MICROSECOND', '2006-01-01 00:00:00.0000000', '2006-01-01 00:00:00.123456789'),
DATEDIFF('MCS', '2006-01-01 00:00:00.0000000', '2006-01-01 00:00:00.123456789'),
......@@ -212,46 +167,48 @@ SELECT DATEDIFF('WEEK', DATE '1969-12-28', DATE '1969-12-29'), DATEDIFF('ISO_WEE
> rows: 1
SELECT DATEDIFF('QUARTER', DATE '2009-12-30', DATE '2009-12-31');
> 0
> -
> 0
> rows: 1
>> 0
SELECT DATEDIFF('QUARTER', DATE '2010-01-01', DATE '2009-12-31');
> -1
> --
> -1
> rows: 1
>> -1
SELECT DATEDIFF('QUARTER', DATE '2010-01-01', DATE '2010-01-02');
> 0
> -
> 0
> rows: 1
>> 0
SELECT DATEDIFF('QUARTER', DATE '2010-01-01', DATE '2010-03-31');
> 0
> -
> 0
> rows: 1
>> 0
SELECT DATEDIFF('QUARTER', DATE '-1000-01-01', DATE '2000-01-01');
> 12000
> -----
> 12000
> rows: 1
>> 12000
SELECT DATEDIFF('TIMEZONE_HOUR', TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+01',
TIMESTAMP WITH TIME ZONE '2012-02-02 12:00:00+02');
> 1
> -
> 1
> rows: 1
>> 1
SELECT DATEDIFF('TIMEZONE_MINUTE', TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+01:15',
TIMESTAMP WITH TIME ZONE '2012-02-02 12:00:00+02');
> 45
> --
> 45
> rows: 1
>> 45
select datediff('HOUR', timestamp '2007-01-06 10:00:00Z', '2007-01-06 10:00:00Z');
>> 0
select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00:00+02:00');
>> -1
select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00:00-02:00');
>> 3
select timestampdiff(month, '2003-02-01','2003-05-01');
>> 3
select timestampdiff(YEAR,'2002-05-01','2001-01-01');
>> -1
select timestampdiff(YEAR,'2017-01-01','2016-12-31 23:59:59');
>> -1
select timestampdiff(YEAR,'2017-01-01','2017-12-31 23:59:59');
>> 0
select timestampdiff(MINUTE,'2003-02-01','2003-05-01 12:05:55');
>> 128885
......@@ -9,11 +9,8 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select dayofmonth(date '2005-09-12') d12 from test;
> D12
> ---
> 12
> rows: 1
select dayofmonth(date '2005-09-12') from test;
>> 12
drop table test;
> ok
......
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select dayofweek(date '2005-09-12') d2 from test;
> D2
> --
> 2
> rows: 1
select dayofweek(date '2005-09-12') from test;
>> 2
......@@ -10,7 +10,4 @@ insert into test values(1, 'Hello');
> update count: 1
select dayofyear(date '2005-01-01') d1 from test;
> D1
> --
> 1
> rows: 1
>> 1
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select dayname(date '2005-09-12') d_monday from test;
> D_MONDAY
> --------
> Monday
> rows: 1
select dayname(date '2005-09-12') from test;
>> Monday
......@@ -18,64 +18,61 @@ SELECT EXTRACT (NANOSECOND FROM TIME '10:00:00.123456789'),
> rows: 1
select EXTRACT (EPOCH from time '00:00:00');
> 0
>> 0
select EXTRACT (EPOCH from time '10:00:00');
> 36000
>> 36000
select EXTRACT (EPOCH from time '10:00:00.123456');
> 36000.123456
>> 36000.123456
select EXTRACT (EPOCH from date '1970-01-01');
> 0
>> 0
select EXTRACT (EPOCH from date '2000-01-03');
> 946857600
>> 946857600
select EXTRACT (EPOCH from timestamp '1970-01-01 00:00:00');
> 0
>> 0
select EXTRACT (EPOCH from timestamp '1970-01-03 12:00:00.123456');
> 216000.123456
>> 216000.123456
select EXTRACT (EPOCH from timestamp '2000-01-03 12:00:00.123456');
> 946900800.123456
>> 946900800.123456
select EXTRACT (EPOCH from timestamp '2500-01-03 12:00:00.654321');
> 16725441600.654321
>> 16725441600.654321
select EXTRACT (EPOCH from timestamp with time zone '1970-01-01 00:00:00+05');
> -18000
>> -18000
select EXTRACT (EPOCH from timestamp with time zone '1970-01-03 12:00:00.123456+05');
> 198000.123456
>> 198000.123456
select EXTRACT (EPOCH from timestamp with time zone '2000-01-03 12:00:00.123456+05');
> 946882800.123456
>> 946882800.123456
select extract(EPOCH from '2001-02-03 14:15:16');
> 981209716
>> 981209716
SELECT EXTRACT(TIMEZONE_HOUR FROM TIMESTAMP WITH TIME ZONE '2010-01-02 5:00:00+07:15');
> 7
> -
> 7
> rows: 1
>> 7
SELECT EXTRACT(TIMEZONE_HOUR FROM TIMESTAMP WITH TIME ZONE '2010-01-02 5:00:00-08:30');
> -8
> --
> -8
> rows: 1
>> -8
SELECT EXTRACT(TIMEZONE_MINUTE FROM TIMESTAMP WITH TIME ZONE '2010-01-02 5:00:00+07:15');
> 15
> --
> 15
> rows: 1
>> 15
SELECT EXTRACT(TIMEZONE_MINUTE FROM TIMESTAMP WITH TIME ZONE '2010-01-02 5:00:00-08:30');
> -30
> ---
> -30
> rows: 1
>> -30
select extract(hour from timestamp '2001-02-03 14:15:16');
>> 14
select extract(hour from '2001-02-03 14:15:16');
>> 14
select extract(week from timestamp '2001-02-03 14:15:16');
>> 5
......@@ -4,43 +4,22 @@
--
CALL FORMATDATETIME(PARSEDATETIME('2001-02-03 04:05:06 GMT', 'yyyy-MM-dd HH:mm:ss z', 'en', 'GMT'), 'EEE, d MMM yyyy HH:mm:ss z', 'en', 'GMT');
> 'Sat, 3 Feb 2001 04:05:06 GMT'
> ------------------------------
> Sat, 3 Feb 2001 04:05:06 GMT
> rows: 1
>> Sat, 3 Feb 2001 04:05:06 GMT
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', 'yyyy-MM-dd HH:mm:ss');
> '2001-02-03 04:05:06'
> ---------------------
> 2001-02-03 04:05:06
> rows: 1
>> 2001-02-03 04:05:06
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', 'MM/dd/yyyy HH:mm:ss');
> '02/03/2001 04:05:06'
> ---------------------
> 02/03/2001 04:05:06
> rows: 1
>> 02/03/2001 04:05:06
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', 'd. MMMM yyyy', 'de');
> '3. Februar 2001'
> -----------------
> 3. Februar 2001
> rows: 1
>> 3. Februar 2001
CALL FORMATDATETIME(PARSEDATETIME('Sat, 3 Feb 2001 04:05:06 GMT', 'EEE, d MMM yyyy HH:mm:ss z', 'en', 'GMT'), 'yyyy-MM-dd HH:mm:ss', 'en', 'GMT');
> '2001-02-03 04:05:06'
> ---------------------
> 2001-02-03 04:05:06
> rows: 1
>> 2001-02-03 04:05:06
SELECT FORMATDATETIME(TIMESTAMP WITH TIME ZONE '2010-05-06 07:08:09.123Z', 'yyyy-MM-dd HH:mm:ss.SSS z') AS S;
> S
> ---------------------------
> 2010-05-06 07:08:09.123 UTC
> rows: 1
SELECT FORMATDATETIME(TIMESTAMP WITH TIME ZONE '2010-05-06 07:08:09.123Z', 'yyyy-MM-dd HH:mm:ss.SSS z');
>> 2010-05-06 07:08:09.123 UTC
SELECT FORMATDATETIME(TIMESTAMP WITH TIME ZONE '2010-05-06 07:08:09.123+13:30', 'yyyy-MM-dd HH:mm:ss.SSS z') AS S;
> S
> ---------------------------------
> 2010-05-06 07:08:09.123 GMT+13:30
> rows: 1
SELECT FORMATDATETIME(TIMESTAMP WITH TIME ZONE '2010-05-06 07:08:09.123+13:30', 'yyyy-MM-dd HH:mm:ss.SSS z');
>> 2010-05-06 07:08:09.123 GMT+13:30
......@@ -9,11 +9,8 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select hour(time '23:10:59') d23 from test;
> D23
> ---
> 23
> rows: 1
select hour(time '23:10:59') from test;
>> 23
drop table test;
> ok
......@@ -33,3 +30,6 @@ select hour(ts) h from test;
drop table test;
> ok
select hour('2001-02-03 14:15:16');
>> 14
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select minute(timestamp '2005-01-01 23:10:59') d10 from test;
> D10
> ---
> 10
> rows: 1
select minute(timestamp '2005-01-01 23:10:59') from test;
>> 10
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select month(date '2005-09-25') d9 from test;
> D9
> --
> 9
> rows: 1
select month(date '2005-09-25') from test;
>> 9
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select monthname(date '2005-09-12') d_sept from test;
> D_SEPT
> ---------
> September
> rows: 1
select monthname(date '2005-09-12') from test;
>> September
......@@ -4,14 +4,7 @@
--
CALL PARSEDATETIME('3. Februar 2001', 'd. MMMM yyyy', 'de');
> TIMESTAMP '2001-02-03 00:00:00'
> -------------------------------
> 2001-02-03 00:00:00
> rows: 1
>> 2001-02-03 00:00:00
CALL PARSEDATETIME('02/03/2001 04:05:06', 'MM/dd/yyyy HH:mm:ss');
> TIMESTAMP '2001-02-03 04:05:06'
> -------------------------------
> 2001-02-03 04:05:06
> rows: 1
>> 2001-02-03 04:05:06
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select quarter(date '2005-09-01') d3 from test;
> D3
> --
> 3
> rows: 1
select quarter(date '2005-09-01') from test;
>> 3
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select second(timestamp '2005-01-01 23:10:59') d59 from test;
> D59
> ---
> 59
> rows: 1
select second(timestamp '2005-01-01 23:10:59') from test;
>> 59
......@@ -3,26 +3,14 @@
-- Initial Developer: H2 Group
--
select trunc('2015-05-29 15:00:00') R;
> R
> -------------------
> 2015-05-29 00:00:00
> rows: 1
select trunc('2015-05-29 15:00:00');
>> 2015-05-29 00:00:00
select trunc('2015-05-29') R;
> R
> -------------------
> 2015-05-29 00:00:00
> rows: 1
select trunc('2015-05-29');
>> 2015-05-29 00:00:00
select trunc(timestamp '2000-01-01 10:20:30.0') R;
> R
> -------------------
> 2000-01-01 00:00:00
> rows: 1
select trunc(timestamp '2000-01-01 10:20:30.0');
>> 2000-01-01 00:00:00
select trunc(timestamp '2001-01-01 14:00:00.0') R;
> R
> -------------------
> 2001-01-01 00:00:00
> rows: 1
select trunc(timestamp '2001-01-01 14:00:00.0');
>> 2001-01-01 00:00:00
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select week(date '2003-01-09') d1 from test;
> D1
> --
> 2
> rows: 1
select week(date '2003-01-09') from test;
>> 2
......@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select year(date '2005-01-01') d2005 from test;
> D2005
> -----
> 2005
> rows: 1
select year(date '2005-01-01') from test;
>> 2005
......@@ -14,46 +14,8 @@ select 1.0000000 / 3 * 0.00000;
> 0.0000000000000000000000000000000000000;
select 1.0000000 / 3 * 0.000000;
> 0E-38;
select substr('[Hello]', 2, 5);
> Hello;
select substr('Hello World', -5);
> World;
create table test(id null);
drop table test;
select select decode(null, null, 'a');
> a;
select select decode(1, 1, 'a');
> a;
select select decode(1, 2, 'a');
> null;
select select decode(1, 1, 'a', 'else');
> a;
select select decode(1, 2, 'a', 'else');
> else;
select decode(4.0, 2.0, 2.0, 3.0, 3.0);
> null;
select decode('3', 2.0, 2.0, 3, 3.0);
> 3.0;
select decode(4.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 9.0);
> 4.0;
select array_contains((4.0, 2.0, 2.0), 2.0);
> TRUE;
select array_contains((4.0, 2.0, 2.0), 5.0);
> FALSE;
select array_contains(('one', 'two'), 'one');
> TRUE;
select array_contains(('one', 'two'), 'xxx');
> FALSE;
select array_contains(('one', 'two'), null);
> FALSE;
select array_contains((null, 'two'), null);
> TRUE;
select array_contains(null, 'one');
> FALSE;
select array_contains(((1, 2), (3, 4)), (1, 2));
> TRUE;
select array_contains(((1, 2), (3, 4)), (5, 6));
> FALSE;
select * from (select group_concat(distinct 1) from system_range(1, 3));
> 1;
select sum(mod(x, 2) = 1) from system_range(1, 10);
......@@ -69,50 +31,8 @@ select {fn TIMESTAMPADD(SQL_TSI_DAY, 1, {ts '2011-10-20 20:30:40.001'})};
> 2011-10-21 20:30:40.001;
select {fn TIMESTAMPADD(SQL_TSI_SECOND, 1, cast('2011-10-20 20:30:40.001' as timestamp))};
> 2011-10-20 20:30:41.001;
select cast(128 as binary);
> 00000080;
select cast(65535 as binary);
> 0000ffff;
select cast(cast('ff' as binary) as tinyint) x;
> -1;
select cast(cast('7f' as binary) as tinyint) x;
> 127;
select cast(cast('ff' as binary) as smallint) x;
> 255;
select cast(cast('ff' as binary) as int) x;
> 255;
select cast(cast('ffff' as binary) as long) x;
> 65535;
select cast(cast(65535 as long) as binary);
> 000000000000ffff;
select cast(cast(-1 as tinyint) as binary);
> ff;
select cast(cast(-1 as smallint) as binary);
> ffff;
select cast(cast(-1 as int) as binary);
> ffffffff;
select cast(cast(-1 as long) as binary);
> ffffffffffffffff;
select cast(cast(1 as tinyint) as binary);
> 01;
select cast(cast(1 as smallint) as binary);
> 0001;
select cast(cast(1 as int) as binary);
> 00000001;
select cast(cast(1 as long) as binary);
> 0000000000000001;
select cast(X'ff' as tinyint);
> -1;
select cast(X'ffff' as smallint);
> -1;
select cast(X'ffffffff' as int);
> -1;
select cast(X'ffffffffffffffff' as long);
> -1;
select N'test';
> test;
select cast(' 011 ' as int);
> 11;
select E'test\\test';
> test\test;
create table a(id int) as select null;
......@@ -156,24 +76,8 @@ alter table test alter column id drop not null;
select is_nullable from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID';
> YES;
drop table test;
select cast(cast(0.1 as real) as decimal);
> 0.1;
select cast(cast(95605327.73 as float) as decimal);
> 95605327.73;
select timestampdiff(month, '2003-02-01','2003-05-01');
> 3;
select timestampdiff(YEAR,'2002-05-01','2001-01-01');
> -1;
select timestampdiff(YEAR,'2017-01-01','2016-12-31 23:59:59');
> -1;
select timestampdiff(YEAR,'2017-01-01','2017-12-31 23:59:59');
> 0;
select timestampdiff(MINUTE,'2003-02-01','2003-05-01 12:05:55');
> 128885;
select x from (select *, rownum as r from system_range(1, 3)) where r=2;
> 2;
select cast(cast('01020304-0506-0708-090a-0b0c0d0e0f00' as uuid) as binary);
> 0102030405060708090a0b0c0d0e0f00;
create table test(name varchar(255)) as select 'Hello+World+';
select count(*) from test where name like 'Hello++World++' escape '+';
> 1;
......@@ -356,15 +260,6 @@ CREATE TABLE Contact.Contact (id BIGINT primary key, FOREIGN KEY (id) REFERENCES
drop schema contact cascade;
drop table account, person;
select extract(hour from timestamp '2001-02-03 14:15:16');
> 14;
select extract(hour from '2001-02-03 14:15:16');
> 14;
select hour('2001-02-03 14:15:16');
> 14;
select extract(week from timestamp '2001-02-03 14:15:16');
> 5;
CREATE TABLE TEST(A int NOT NULL, B int NOT NULL, C int) ;
ALTER TABLE TEST ADD CONSTRAINT CON UNIQUE(A,B);
ALTER TABLE TEST DROP C;
......@@ -385,10 +280,6 @@ select count(*) from (select * from (select * from test union select * from test
select 1 from ((test d1 inner join test d2 on d1.id = d2.id) inner join test d3 on d1.id = d3.id) inner join test d4 on d4.id = d1.id;
drop table test;
select lpad('string', 10, '+');
> ++++string;
select rpad('string', 10, '+');
> string++++;
select lpad('string', 10);
> string;
......@@ -561,12 +452,6 @@ select date '+0011-01-01';
> 0011-01-01;
select date'-0010-01-01';
> -10-01-01;
select datediff('HOUR', timestamp '2007-01-06 10:00:00Z', '2007-01-06 10:00:00Z');
> 0;
select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00:00+02:00');
> -1;
select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00:00-02:00');
> 3;
create schema TEST_SCHEMA;
create table TEST_SCHEMA.test(id int);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论