mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Remove obsolete test suite
This commit is contained in:
@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
This directory contains our feeble collection of tests. To test foo.sql do
|
|
||||||
psql -q < foo.sql >! foo.out
|
|
||||||
diff foo.out results/foo.sql.out
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- agg.sql-
|
|
||||||
-- test aggregates
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: agg.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
create table agga (a integer);
|
|
||||||
create table aggb (b smallint);
|
|
||||||
create table aggc (c float);
|
|
||||||
create table aggd (d float8);
|
|
||||||
insert into agga values (1);
|
|
||||||
insert into agga values (1);
|
|
||||||
insert into agga values (4);
|
|
||||||
insert into agga values (3);
|
|
||||||
select * from agga;
|
|
||||||
insert into aggb values (10);
|
|
||||||
insert into aggb values (45);
|
|
||||||
insert into aggb values (10);
|
|
||||||
insert into aggb values (30);
|
|
||||||
select * from aggb;
|
|
||||||
insert into aggc values (210.3);
|
|
||||||
insert into aggc values (4.45);
|
|
||||||
insert into aggc values (310);
|
|
||||||
insert into aggc values (310);
|
|
||||||
select * from aggc;
|
|
||||||
insert into aggd values ('-210.3'::float8);
|
|
||||||
insert into aggd values ('210.3'::float8);
|
|
||||||
insert into aggd values ('4.45'::float8);
|
|
||||||
insert into aggd values ('10310.33336'::float8);
|
|
||||||
insert into aggd values ('10310.33335'::float8);
|
|
||||||
select * from aggd;
|
|
||||||
|
|
||||||
select count(*) from agga;
|
|
||||||
select count(*), avg(a) from agga;
|
|
||||||
select avg(a), max(a) from agga;
|
|
||||||
select sum(a), max(a) from agga;
|
|
||||||
|
|
||||||
select avg(c) from aggc;
|
|
||||||
select sum(c) from aggc;
|
|
||||||
select max(c) from aggc;
|
|
||||||
select min(c) from aggc;
|
|
||||||
|
|
||||||
select count(*), avg(a), sum(a), max(a), min(a) from agga;
|
|
||||||
select count(*), avg(b), sum(b), max(b), min(b) from aggb;
|
|
||||||
select count(*), avg(c), sum(c), max(c), min(c) from aggc;
|
|
||||||
select count(*), avg(d), sum(d), max(d), min(d) from aggd;
|
|
||||||
|
|
||||||
create table agge (e integer);
|
|
||||||
-- aggregates on an empty table
|
|
||||||
select count(*) from agge;
|
|
||||||
select avg(e) from agge;
|
|
||||||
select sum(e) from agge;
|
|
||||||
select sum(e) from agge;
|
|
||||||
select min(e) from agge;
|
|
||||||
|
|
||||||
create table aggf (x int, y int);
|
|
||||||
insert into aggf (x) values (1);
|
|
||||||
insert into aggf (y) values (2);
|
|
||||||
insert into aggf values (10, 20);
|
|
||||||
select * from aggf;
|
|
||||||
select count(*) from aggf;
|
|
||||||
select count(x), count(y) from aggf;
|
|
||||||
select avg(x), avg(y) from aggf;
|
|
||||||
|
|
||||||
drop table agga;
|
|
||||||
drop table aggb;
|
|
||||||
drop table aggc;
|
|
||||||
drop table aggd;
|
|
||||||
drop table agge;
|
|
||||||
drop table aggf;
|
|
@ -1,30 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- date.sql-
|
|
||||||
-- test DATE adt
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: date.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
create table dd (d date);
|
|
||||||
insert into dd values ('06-22-1995');
|
|
||||||
insert into dd values ('05-31-1994');
|
|
||||||
insert into dd values ('02-29-1996');
|
|
||||||
insert into dd values ('12-02-1993');
|
|
||||||
insert into dd values ('05-31-1994');
|
|
||||||
insert into dd values ('10-20-1970');
|
|
||||||
select * from dd;
|
|
||||||
select * from dd order by d;
|
|
||||||
select * from dd order by d using >;
|
|
||||||
select * from dd where d = '05-31-1994';
|
|
||||||
select * from dd where d <> '05-31-1994';
|
|
||||||
select * from dd where d < '05-31-1994';
|
|
||||||
select * from dd where d <= '05-31-1994';
|
|
||||||
select * from dd where d > '05-31-1994';
|
|
||||||
select * from dd where d >= '05-31-1994';
|
|
||||||
create index dd_ind on dd using btree (d date_ops);
|
|
||||||
drop table dd;
|
|
@ -1,113 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- float.sql-
|
|
||||||
-- test float4, float8 adt
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: float.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
--
|
|
||||||
-- float4
|
|
||||||
--
|
|
||||||
create table fl (x float4);
|
|
||||||
insert into fl values ( 3.14 );
|
|
||||||
insert into fl values ( 147.0 );
|
|
||||||
insert into fl values ( 3.14 );
|
|
||||||
insert into fl values ( -3.14 );
|
|
||||||
select * from fl;
|
|
||||||
-- float literals
|
|
||||||
select * from fl where x = 3.14;
|
|
||||||
select * from fl where x <> 3.14;
|
|
||||||
select * from fl where x < 3.14;
|
|
||||||
select * from fl where x <= 3.14;
|
|
||||||
select * from fl where x > 3.14;
|
|
||||||
select * from fl where x >= 3.14;
|
|
||||||
-- adt constant without cast (test coercion)
|
|
||||||
select * from fl where x = '3.14';
|
|
||||||
select * from fl where x <> '3.14';
|
|
||||||
select * from fl where x < '3.14';
|
|
||||||
select * from fl where x <= '3.14';
|
|
||||||
select * from fl where x > '3.14';
|
|
||||||
select * from fl where x >= '3.14';
|
|
||||||
-- adt constant with float4 cast (test float4 opers)
|
|
||||||
select * from fl where x = '3.14'::float4;
|
|
||||||
select * from fl where x <> '3.14'::float4;
|
|
||||||
select * from fl where x < '3.14'::float4;
|
|
||||||
select * from fl where x <= '3.14'::float4;
|
|
||||||
select * from fl where x > '3.14'::float4;
|
|
||||||
select * from fl where x >= '3.14'::float4;
|
|
||||||
-- adt constant with float8 cast (test float48 opers)
|
|
||||||
select * from fl where x = '3.14'::float8;
|
|
||||||
select * from fl where x <> '3.14'::float8;
|
|
||||||
select * from fl where x < '3.14'::float8;
|
|
||||||
select * from fl where x <= '3.14'::float8;
|
|
||||||
select * from fl where x > '3.14'::float8;
|
|
||||||
select * from fl where x >= '3.14'::float8;
|
|
||||||
|
|
||||||
-- try other operators
|
|
||||||
update fl set x = x + 2.2;
|
|
||||||
select * from fl;
|
|
||||||
update fl set x = x - 2.2;
|
|
||||||
select * from fl;
|
|
||||||
update fl set x = x * 2.2;
|
|
||||||
select * from fl;
|
|
||||||
update fl set x = x / 2.2;
|
|
||||||
select * from fl;
|
|
||||||
|
|
||||||
--
|
|
||||||
-- float8
|
|
||||||
--
|
|
||||||
create table fl8 (y float8);
|
|
||||||
insert into fl8 values ( '3.14'::float8 );
|
|
||||||
insert into fl8 values ( '147.0'::float8 );
|
|
||||||
insert into fl8 values ( '3.140000001'::float8 );
|
|
||||||
insert into fl8 values ( '-3.14'::float8);
|
|
||||||
select * from fl8;
|
|
||||||
-- float literals
|
|
||||||
select * from fl8 where y = 3.14;
|
|
||||||
select * from fl8 where y <> 3.14;
|
|
||||||
select * from fl8 where y < 3.14;
|
|
||||||
select * from fl8 where y <= 3.14;
|
|
||||||
select * from fl8 where y > 3.14;
|
|
||||||
select * from fl8 where y >= 3.14;
|
|
||||||
-- adt constant without cast (test coercion)
|
|
||||||
select * from fl8 where y = '3.14';
|
|
||||||
select * from fl8 where y <> '3.14';
|
|
||||||
select * from fl8 where y < '3.14';
|
|
||||||
select * from fl8 where y <= '3.14';
|
|
||||||
select * from fl8 where y > '3.14';
|
|
||||||
select * from fl8 where y >= '3.14';
|
|
||||||
-- adt constant with float4 cast (test float84 opers)
|
|
||||||
select * from fl8 where y = '3.14'::float4;
|
|
||||||
select * from fl8 where y <> '3.14'::float4;
|
|
||||||
select * from fl8 where y < '3.14'::float4;
|
|
||||||
select * from fl8 where y <= '3.14'::float4;
|
|
||||||
select * from fl8 where y > '3.14'::float4;
|
|
||||||
select * from fl8 where y >= '3.14'::float4;
|
|
||||||
-- adt constant with float8 cast (test float8 opers)
|
|
||||||
select * from fl8 where y = '3.14'::float8;
|
|
||||||
select * from fl8 where y <> '3.14'::float8;
|
|
||||||
select * from fl8 where y < '3.14'::float8;
|
|
||||||
select * from fl8 where y <= '3.14'::float8;
|
|
||||||
select * from fl8 where y > '3.14'::float8;
|
|
||||||
select * from fl8 where y >= '3.14'::float8;
|
|
||||||
|
|
||||||
-- try other operators
|
|
||||||
update fl8 set y = y + '2.2'::float8;
|
|
||||||
select * from fl8;
|
|
||||||
update fl8 set y = y - '2.2'::float8;
|
|
||||||
select * from fl8;
|
|
||||||
update fl8 set y = y * '2.2'::float8;
|
|
||||||
select * from fl8;
|
|
||||||
update fl8 set y = y / '2.2'::float8;
|
|
||||||
select * from fl8;
|
|
||||||
|
|
||||||
-- drop tables
|
|
||||||
|
|
||||||
drop table fl;
|
|
||||||
drop table fl8;
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- group.sql-
|
|
||||||
-- test GROUP BY (with aggregates)
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: group.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
create table G (x int4, y int4, z int4);
|
|
||||||
insert into G values (1, 2, 6);
|
|
||||||
insert into G values (1, 3, 7);
|
|
||||||
insert into G values (1, 3, 8);
|
|
||||||
insert into G values (1, 4, 9);
|
|
||||||
insert into G values (1, 4, 10);
|
|
||||||
insert into G values (1, 4, 11);
|
|
||||||
insert into G values (1, 5, 12);
|
|
||||||
insert into G values (1, 5, 13);
|
|
||||||
|
|
||||||
select x from G group by x;
|
|
||||||
select y from G group by y;
|
|
||||||
select z from G group by z;
|
|
||||||
select x, y from G group by x, y;
|
|
||||||
select x, y from G group by y, x;
|
|
||||||
select x, y, z from G group by x, y, z;
|
|
||||||
|
|
||||||
-- mixed target list (aggregates and group columns)
|
|
||||||
select count(y) from G group by y;
|
|
||||||
select x, count(x) from G group by x;
|
|
||||||
select y, count(y), sum(G.z) from G group by y;
|
|
||||||
select sum(G.x), sum(G.y), z from G group by z;
|
|
||||||
select y, avg(z) from G group by y;
|
|
||||||
|
|
||||||
-- group attr not in target list
|
|
||||||
select sum(x) from G group by y;
|
|
||||||
select sum(x), sum(z) from G group by y;
|
|
||||||
select sum(z) from G group by y;
|
|
||||||
|
|
||||||
-- aggregates in expressions
|
|
||||||
select sum(G.z)/count(G.z), avg(G.z) from G group by y;
|
|
||||||
|
|
||||||
-- with qualifications
|
|
||||||
select y, count(y) from G where z < 11 group by y;
|
|
||||||
select y, count(y) from G where z > 9 group by y;
|
|
||||||
select y, count(y) from G where z > 8 and z < 12 group by y;
|
|
||||||
select y, count(y) from G where y = 4 group by y;
|
|
||||||
select y, count(y) from G where y > 10 group by y;
|
|
||||||
|
|
||||||
-- with order by
|
|
||||||
select y, count(y) as c from G group by y order by c;
|
|
||||||
select y, count(y) as c from G group by y order by c, y;
|
|
||||||
select y, count(y) as c from G where z > 20 group by y order by c;
|
|
||||||
-- just to make sure we didn't screw up order by
|
|
||||||
select x, y from G order by y, x;
|
|
||||||
|
|
||||||
-- with having
|
|
||||||
-- HAVING clause is not implemented yet
|
|
||||||
--select count(y) from G having count(y) > 1
|
|
||||||
--select count(y) from G group by y having y > 3
|
|
||||||
--select y from G group by y having y > 3
|
|
||||||
--select y from G where z > 10 group by y having y > 3
|
|
||||||
--select y from G group by y having y > 10
|
|
||||||
--select count(G.y) from G group by y having y > 10
|
|
||||||
--select y from G where z > 20 group by y having y > 3
|
|
||||||
|
|
||||||
create table H (a int4, b int4);
|
|
||||||
insert into H values (3, 9)
|
|
||||||
insert into H values (4, 13);
|
|
||||||
create table F (p int4);
|
|
||||||
insert into F values (7)
|
|
||||||
insert into F values (11);
|
|
||||||
|
|
||||||
-- joins
|
|
||||||
select y from G, H where G.y = H.a group by y;
|
|
||||||
select sum(b) from G, H where G.y = H.a group by y;
|
|
||||||
select y, count(y), sum(b) from G, H where G.y = H.a group by y;
|
|
||||||
select a, sum(x), sum(b) from G, H where G.y = H.a group by a;
|
|
||||||
select y, count(*) from G, H where G.z = H.b group by y;
|
|
||||||
select z, sum(y) from G, H, F where G.y = H.a and G.z = F.p group by z;
|
|
||||||
select a, avg(p) from G, H, F where G.y = H.a and G.z = F.p group by a;
|
|
||||||
|
|
||||||
-- just aggregates
|
|
||||||
select sum(x) from G, H where G.y = H.a;
|
|
||||||
select sum(y) from G, H where G.y = H.a;
|
|
||||||
select sum(a) from G, H where G.y = H.a;
|
|
||||||
select sum(b) from G, H where G.y = H.a;
|
|
||||||
select count(*) from G group by y;
|
|
||||||
|
|
||||||
insert into G (y, z) values (6, 14);
|
|
||||||
insert into G (x, z) values (2, 14);
|
|
||||||
select count(*) from G;
|
|
||||||
select count(x), count(y), count(z) from G;
|
|
||||||
select x from G group by x;
|
|
||||||
select y, count(*) from G group by y;
|
|
||||||
|
|
||||||
--
|
|
||||||
drop table G, H, F;
|
|
@ -1,29 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- group_err.sql-
|
|
||||||
-- test illegal use of GROUP BY (with aggregates)
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: group_err.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
create table G_ERR (x int4, y int4, z int4);
|
|
||||||
|
|
||||||
select x from G_ERR group by y;
|
|
||||||
select x, sum(z) from G_ERR group by y;
|
|
||||||
select x, count(x) from G_ERR;
|
|
||||||
|
|
||||||
select max(count(x)) from G_ERR;
|
|
||||||
|
|
||||||
select x from G_ERR where count(x) = 1;
|
|
||||||
|
|
||||||
create table H_ERR (a int4, b int4);
|
|
||||||
|
|
||||||
select y, a, count(y), sum(b)
|
|
||||||
from G_ERR, H_ERR
|
|
||||||
where G_ERR.y = H_ERR.a group by y;
|
|
||||||
|
|
||||||
drop table G_ERR, H_ERR;
|
|
@ -1,73 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- inh.sql-
|
|
||||||
-- checks inheritance
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: inh.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
create table person (name text, age int4, location point);
|
|
||||||
create table man () inherits(person);
|
|
||||||
create table emp (salary int4, manager char16) inherits(person);
|
|
||||||
create table student (gpa float8) inherits (person);
|
|
||||||
create table stud_emp (percent int4) inherits (emp, student);
|
|
||||||
create table female_stud_emp () inherits(stud_emp);
|
|
||||||
|
|
||||||
-- attr order: name, age, location
|
|
||||||
select * from person;
|
|
||||||
select * from man;
|
|
||||||
-- attr order: name, age, location, salary, manager
|
|
||||||
select * from emp;
|
|
||||||
-- attr order: name, age, location, gpa
|
|
||||||
select * from student;
|
|
||||||
-- attr order: name, age, location, salary, manager, gpa, percent
|
|
||||||
select * from stud_emp;
|
|
||||||
select * from female_stud_emp;
|
|
||||||
|
|
||||||
insert into person values ('andy', 14, '(1,1)');
|
|
||||||
insert into emp values ('betty', 20, '(2, 1)', 1000, 'mandy');
|
|
||||||
insert into student values ('cy', 45, '(3, 2)', 1.9);
|
|
||||||
insert into stud_emp values ('danny', 19, '(3.3, 4.55)', 400, 'mandy', 3.9);
|
|
||||||
insert into man values ('fred', 2, '(0, 0)');
|
|
||||||
insert into female_stud_emp values ('gina', 16, '(10, 10)', 500, 'mandy', 3.0);
|
|
||||||
|
|
||||||
-- andy
|
|
||||||
select * from person;
|
|
||||||
|
|
||||||
-- betty
|
|
||||||
select * from emp;
|
|
||||||
|
|
||||||
-- cy
|
|
||||||
select * from student;
|
|
||||||
|
|
||||||
-- danny
|
|
||||||
select * from stud_emp;
|
|
||||||
|
|
||||||
-- fred
|
|
||||||
select * from man;
|
|
||||||
|
|
||||||
-- gina
|
|
||||||
select * from female_stud_emp;
|
|
||||||
|
|
||||||
-- andy, betty, cy, danny, fred, gina
|
|
||||||
select * from person*;
|
|
||||||
|
|
||||||
-- betty, danny, gina
|
|
||||||
select * from emp*;
|
|
||||||
|
|
||||||
-- cy, danny, gina
|
|
||||||
select * from student*;
|
|
||||||
|
|
||||||
-- danny, gina
|
|
||||||
select * from stud_emp*;
|
|
||||||
|
|
||||||
drop table female_stud_emp;
|
|
||||||
drop table stud_emp;
|
|
||||||
drop table student;
|
|
||||||
drop table emp;
|
|
||||||
drop table man;
|
|
||||||
drop table person;
|
|
@ -1,40 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- joins.sql-
|
|
||||||
-- test joins
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: join.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
create table foo (x int4, y int4);
|
|
||||||
create table bar (p int4, q int4);
|
|
||||||
create table baz (a int4, b int4);
|
|
||||||
|
|
||||||
insert into foo values (1, 1);
|
|
||||||
insert into foo values (2, 2);
|
|
||||||
insert into bar values (1, 1);
|
|
||||||
insert into baz values (1, 1);
|
|
||||||
insert into baz values (2, 2);
|
|
||||||
|
|
||||||
select * from foo,bar,baz
|
|
||||||
where foo.x=bar.p and bar.p=baz.a and baz.b=foo.y;
|
|
||||||
|
|
||||||
select * from foo,bar,baz
|
|
||||||
where foo.y=bar.p and bar.p=baz.a and baz.b=foo.x and foo.y=bar.q;
|
|
||||||
|
|
||||||
select * from foo,bar,baz
|
|
||||||
where foo.x=bar.q and bar.p=baz.b and baz.b=foo.y and foo.y=bar.q
|
|
||||||
and bar.p=baz.a;
|
|
||||||
|
|
||||||
select * from foo,bar,baz
|
|
||||||
where foo.y=bar.p and bar.q=baz.b and baz.b=foo.x and foo.x=bar.q
|
|
||||||
and bar.p=baz.a and bar.p=baz.a;
|
|
||||||
|
|
||||||
select bar.p from foo, bar;
|
|
||||||
select foo.x from foo, bar where foo.x = bar.p;
|
|
||||||
|
|
||||||
drop table foo, bar, baz;
|
|
@ -1,27 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- oper.sql-
|
|
||||||
-- test operators
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: oper.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- test creation
|
|
||||||
create operator ##+ (leftarg=int4, rightarg=int4, procedure = int4pl);\g
|
|
||||||
create operator ##+ (rightarg=int4, procedure=int4fac);\g
|
|
||||||
create operator ##+ (leftarg=int4, procedure=int4inc);\g
|
|
||||||
|
|
||||||
select 4 ##+ 4;\g
|
|
||||||
select ##+ 4;\g
|
|
||||||
|
|
||||||
-- why "select 4 ##+" does not work?
|
|
||||||
select (4 ##+);\g
|
|
||||||
|
|
||||||
drop operator ##+(int4,int4);\g
|
|
||||||
drop operator ##+(none, int4);\g
|
|
||||||
drop operator ##+(int4, none);\g
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- parse.sql-
|
|
||||||
-- checks the parser
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: parse.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
create table foo (x int4, y int4, z int4);
|
|
||||||
create table bar (x int4, y int4, z int4);
|
|
||||||
create table baz (a int4, b int4);
|
|
||||||
|
|
||||||
insert into foo values (1, 2, 3);
|
|
||||||
insert into foo values (4, 5, 6);
|
|
||||||
insert into foo values (7, 8, 9);
|
|
||||||
insert into bar values (11, 12, 13);
|
|
||||||
insert into bar values (14, 15, 16);
|
|
||||||
insert into bar values (17, 18, 19);
|
|
||||||
insert into baz values (99, 88);
|
|
||||||
insert into baz values (77, 66);
|
|
||||||
|
|
||||||
-- once upon a time, this becomes a join of foo and f:
|
|
||||||
select * from foo f where f.x = 4;
|
|
||||||
select * from foo f, foo where f.x > foo.x;
|
|
||||||
select * from foo f, foo where f.x = 1 and foo.z > f.z;
|
|
||||||
|
|
||||||
-- not standard SQL, POSTQUEL semantics
|
|
||||||
-- update foo set x = f.x from foo f where foo.x = 1 and f.x = 7
|
|
||||||
-- select * from foo
|
|
||||||
|
|
||||||
-- fix error message:
|
|
||||||
--select foo.x from foo,bar,baz where foo.x=bar.x and bar.y=baz.x and baz.x=foo.x
|
|
||||||
|
|
||||||
-- see if renaming the column works
|
|
||||||
select y as a, z as b from foo order by a;
|
|
||||||
select foo.y as a, foo.z as b from foo order by b;
|
|
||||||
|
|
||||||
-- column expansion
|
|
||||||
select foo.*, bar.z, baz.* from foo, bar, baz;
|
|
||||||
|
|
||||||
drop table foo, bar, baz;
|
|
@ -1,18 +0,0 @@
|
|||||||
create table quoteTBL (f text);
|
|
||||||
|
|
||||||
insert into quoteTBL values ('hello world');
|
|
||||||
insert into quoteTBL values ('hello '' world');
|
|
||||||
insert into quoteTBL values ('hello \' world');
|
|
||||||
insert into quoteTBL values ('hello \\ world');
|
|
||||||
insert into quoteTBL values ('hello \t world');
|
|
||||||
insert into quoteTBL values ('hello
|
|
||||||
world
|
|
||||||
with
|
|
||||||
newlines
|
|
||||||
');
|
|
||||||
insert into quoteTBL values ('hello " world');
|
|
||||||
insert into quoteTBL values ('');
|
|
||||||
-- bad escape sequence
|
|
||||||
insert into quoteTBL values ('hello \y world');
|
|
||||||
select * from quoteTBL;
|
|
||||||
drop table quoteTBL;
|
|
@ -1,147 +0,0 @@
|
|||||||
QUERY: create table agga (a integer);
|
|
||||||
QUERY: create table aggb (b smallint);
|
|
||||||
QUERY: create table aggc (c float);
|
|
||||||
QUERY: create table aggd (d float8);
|
|
||||||
QUERY: insert into agga values (1);
|
|
||||||
QUERY: insert into agga values (1);
|
|
||||||
QUERY: insert into agga values (4);
|
|
||||||
QUERY: insert into agga values (3);
|
|
||||||
QUERY: select * from agga;
|
|
||||||
a
|
|
||||||
--
|
|
||||||
1
|
|
||||||
1
|
|
||||||
4
|
|
||||||
3
|
|
||||||
QUERY: insert into aggb values (10);
|
|
||||||
QUERY: insert into aggb values (45);
|
|
||||||
QUERY: insert into aggb values (10);
|
|
||||||
QUERY: insert into aggb values (30);
|
|
||||||
QUERY: select * from aggb;
|
|
||||||
b
|
|
||||||
---
|
|
||||||
10
|
|
||||||
45
|
|
||||||
10
|
|
||||||
30
|
|
||||||
QUERY: insert into aggc values (210.3);
|
|
||||||
QUERY: insert into aggc values (4.45);
|
|
||||||
QUERY: insert into aggc values (310);
|
|
||||||
QUERY: insert into aggc values (310);
|
|
||||||
QUERY: select * from aggc;
|
|
||||||
c
|
|
||||||
------
|
|
||||||
210.3
|
|
||||||
4.45
|
|
||||||
310
|
|
||||||
310
|
|
||||||
QUERY: insert into aggd values ('-210.3'::float8);
|
|
||||||
QUERY: insert into aggd values ('210.3'::float8);
|
|
||||||
QUERY: insert into aggd values ('4.45'::float8);
|
|
||||||
QUERY: insert into aggd values ('10310.33336'::float8);
|
|
||||||
QUERY: insert into aggd values ('10310.33335'::float8);
|
|
||||||
QUERY: select * from aggd;
|
|
||||||
d
|
|
||||||
------------
|
|
||||||
-210.3
|
|
||||||
210.3
|
|
||||||
4.45
|
|
||||||
10310.33336
|
|
||||||
10310.33335
|
|
||||||
QUERY: select count(*) from agga;
|
|
||||||
count
|
|
||||||
------
|
|
||||||
4
|
|
||||||
QUERY: select count(*), avg(a) from agga;
|
|
||||||
count avg
|
|
||||||
------ ----
|
|
||||||
4 2
|
|
||||||
QUERY: select avg(a), max(a) from agga;
|
|
||||||
avg max
|
|
||||||
---- ----
|
|
||||||
2 4
|
|
||||||
QUERY: select sum(a), max(a) from agga;
|
|
||||||
sum max
|
|
||||||
---- ----
|
|
||||||
9 4
|
|
||||||
QUERY: select avg(c) from aggc;
|
|
||||||
avg
|
|
||||||
--------
|
|
||||||
208.687
|
|
||||||
QUERY: select sum(c) from aggc;
|
|
||||||
sum
|
|
||||||
-------
|
|
||||||
834.75
|
|
||||||
QUERY: select max(c) from aggc;
|
|
||||||
max
|
|
||||||
----
|
|
||||||
310
|
|
||||||
QUERY: select min(c) from aggc;
|
|
||||||
min
|
|
||||||
-----
|
|
||||||
4.45
|
|
||||||
QUERY: select count(*), avg(a), sum(a), max(a), min(a) from agga;
|
|
||||||
count avg sum max min
|
|
||||||
------ ---- ---- ---- ----
|
|
||||||
4 2 9 4 1
|
|
||||||
QUERY: select count(*), avg(b), sum(b), max(b), min(b) from aggb;
|
|
||||||
count avg sum max min
|
|
||||||
------ ---- ---- ---- ----
|
|
||||||
4 23 95 45 10
|
|
||||||
QUERY: select count(*), avg(c), sum(c), max(c), min(c) from aggc;
|
|
||||||
count avg sum max min
|
|
||||||
------ -------- ------- ---- -----
|
|
||||||
4 208.687 834.75 310 4.45
|
|
||||||
QUERY: select count(*), avg(d), sum(d), max(d), min(d) from aggd;
|
|
||||||
count avg sum max min
|
|
||||||
------ ------------ ------------ ------------ -------
|
|
||||||
5 4125.023342 20625.11671 10310.33336 -210.3
|
|
||||||
QUERY: create table agge (e integer);
|
|
||||||
QUERY: select count(*) from agge;
|
|
||||||
count
|
|
||||||
------
|
|
||||||
0
|
|
||||||
QUERY: select avg(e) from agge;
|
|
||||||
avg
|
|
||||||
----
|
|
||||||
0
|
|
||||||
QUERY: select sum(e) from agge;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
0
|
|
||||||
QUERY: select sum(e) from agge;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
0
|
|
||||||
QUERY: select min(e) from agge;
|
|
||||||
min
|
|
||||||
----
|
|
||||||
|
|
||||||
QUERY: create table aggf (x int, y int);
|
|
||||||
QUERY: insert into aggf (x) values (1);
|
|
||||||
QUERY: insert into aggf (y) values (2);
|
|
||||||
QUERY: insert into aggf values (10, 20);
|
|
||||||
QUERY: select * from aggf;
|
|
||||||
x y
|
|
||||||
--- ---
|
|
||||||
1
|
|
||||||
2
|
|
||||||
10 20
|
|
||||||
QUERY: select count(*) from aggf;
|
|
||||||
count
|
|
||||||
------
|
|
||||||
3
|
|
||||||
QUERY: select count(x), count(y) from aggf;
|
|
||||||
count count
|
|
||||||
------ ------
|
|
||||||
2 2
|
|
||||||
QUERY: select avg(x), avg(y) from aggf;
|
|
||||||
avg avg
|
|
||||||
---- ----
|
|
||||||
5 11
|
|
||||||
QUERY: drop table agga;
|
|
||||||
QUERY: drop table aggb;
|
|
||||||
QUERY: drop table aggc;
|
|
||||||
QUERY: drop table aggd;
|
|
||||||
QUERY: drop table agge;
|
|
||||||
QUERY: drop table aggf;
|
|
@ -1,72 +0,0 @@
|
|||||||
QUERY: create table dd (d date);
|
|
||||||
QUERY: insert into dd values ('06-22-1995');
|
|
||||||
QUERY: insert into dd values ('05-31-1994');
|
|
||||||
QUERY: insert into dd values ('02-29-1996');
|
|
||||||
QUERY: insert into dd values ('12-02-1993');
|
|
||||||
QUERY: insert into dd values ('05-31-1994');
|
|
||||||
QUERY: insert into dd values ('10-20-1970');
|
|
||||||
QUERY: select * from dd;
|
|
||||||
d
|
|
||||||
-----------
|
|
||||||
06-22-1995
|
|
||||||
05-31-1994
|
|
||||||
02-29-1996
|
|
||||||
12-02-1993
|
|
||||||
05-31-1994
|
|
||||||
10-20-1970
|
|
||||||
QUERY: select * from dd order by d;
|
|
||||||
d
|
|
||||||
-----------
|
|
||||||
10-20-1970
|
|
||||||
12-02-1993
|
|
||||||
05-31-1994
|
|
||||||
05-31-1994
|
|
||||||
06-22-1995
|
|
||||||
02-29-1996
|
|
||||||
QUERY: select * from dd order by d using >;
|
|
||||||
d
|
|
||||||
-----------
|
|
||||||
02-29-1996
|
|
||||||
06-22-1995
|
|
||||||
05-31-1994
|
|
||||||
05-31-1994
|
|
||||||
12-02-1993
|
|
||||||
10-20-1970
|
|
||||||
QUERY: select * from dd where d = '05-31-1994';
|
|
||||||
d
|
|
||||||
-----------
|
|
||||||
05-31-1994
|
|
||||||
05-31-1994
|
|
||||||
QUERY: select * from dd where d <> '05-31-1994';
|
|
||||||
d
|
|
||||||
-----------
|
|
||||||
06-22-1995
|
|
||||||
02-29-1996
|
|
||||||
12-02-1993
|
|
||||||
10-20-1970
|
|
||||||
QUERY: select * from dd where d < '05-31-1994';
|
|
||||||
d
|
|
||||||
-----------
|
|
||||||
12-02-1993
|
|
||||||
10-20-1970
|
|
||||||
QUERY: select * from dd where d <= '05-31-1994';
|
|
||||||
d
|
|
||||||
-----------
|
|
||||||
05-31-1994
|
|
||||||
12-02-1993
|
|
||||||
05-31-1994
|
|
||||||
10-20-1970
|
|
||||||
QUERY: select * from dd where d > '05-31-1994';
|
|
||||||
d
|
|
||||||
-----------
|
|
||||||
06-22-1995
|
|
||||||
02-29-1996
|
|
||||||
QUERY: select * from dd where d >= '05-31-1994';
|
|
||||||
d
|
|
||||||
-----------
|
|
||||||
06-22-1995
|
|
||||||
05-31-1994
|
|
||||||
02-29-1996
|
|
||||||
05-31-1994
|
|
||||||
QUERY: create index dd_ind on dd using btree (d date_ops);
|
|
||||||
QUERY: drop table dd;
|
|
@ -1,330 +0,0 @@
|
|||||||
QUERY: create table fl (x float4);
|
|
||||||
QUERY: insert into fl values ( 3.14 );
|
|
||||||
QUERY: insert into fl values ( 147.0 );
|
|
||||||
QUERY: insert into fl values ( 3.14 );
|
|
||||||
QUERY: insert into fl values ( -3.14 );
|
|
||||||
QUERY: select * from fl;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.14
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x = 3.14;
|
|
||||||
x
|
|
||||||
-----
|
|
||||||
3.14
|
|
||||||
3.14
|
|
||||||
QUERY: select * from fl where x <> 3.14;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
147
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x < 3.14;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x <= 3.14;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
3.14
|
|
||||||
3.14
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x > 3.14;
|
|
||||||
x
|
|
||||||
----
|
|
||||||
147
|
|
||||||
QUERY: select * from fl where x >= 3.14;
|
|
||||||
x
|
|
||||||
-----
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.14
|
|
||||||
QUERY: select * from fl where x = '3.14';
|
|
||||||
x
|
|
||||||
-----
|
|
||||||
3.14
|
|
||||||
3.14
|
|
||||||
QUERY: select * from fl where x <> '3.14';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
147
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x < '3.14';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x <= '3.14';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
3.14
|
|
||||||
3.14
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x > '3.14';
|
|
||||||
x
|
|
||||||
----
|
|
||||||
147
|
|
||||||
QUERY: select * from fl where x >= '3.14';
|
|
||||||
x
|
|
||||||
-----
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.14
|
|
||||||
QUERY: select * from fl where x = '3.14'::float4;
|
|
||||||
x
|
|
||||||
-----
|
|
||||||
3.14
|
|
||||||
3.14
|
|
||||||
QUERY: select * from fl where x <> '3.14'::float4;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
147
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x < '3.14'::float4;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x <= '3.14'::float4;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
3.14
|
|
||||||
3.14
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x > '3.14'::float4;
|
|
||||||
x
|
|
||||||
----
|
|
||||||
147
|
|
||||||
QUERY: select * from fl where x >= '3.14'::float4;
|
|
||||||
x
|
|
||||||
-----
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.14
|
|
||||||
QUERY: select * from fl where x = '3.14'::float8;
|
|
||||||
x
|
|
||||||
-----
|
|
||||||
3.14
|
|
||||||
3.14
|
|
||||||
QUERY: select * from fl where x <> '3.14'::float8;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
147
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x < '3.14'::float8;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x <= '3.14'::float8;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
3.14
|
|
||||||
3.14
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl where x > '3.14'::float8;
|
|
||||||
x
|
|
||||||
----
|
|
||||||
147
|
|
||||||
QUERY: select * from fl where x >= '3.14'::float8;
|
|
||||||
x
|
|
||||||
-----
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.14
|
|
||||||
QUERY: update fl set x = x + 2.2;
|
|
||||||
QUERY: select * from fl;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
5.34
|
|
||||||
149.2
|
|
||||||
5.34
|
|
||||||
-0.94
|
|
||||||
QUERY: update fl set x = x - 2.2;
|
|
||||||
QUERY: select * from fl;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.14
|
|
||||||
-3.14
|
|
||||||
QUERY: update fl set x = x * 2.2;
|
|
||||||
QUERY: select * from fl;
|
|
||||||
x
|
|
||||||
-------
|
|
||||||
6.908
|
|
||||||
323.4
|
|
||||||
6.908
|
|
||||||
-6.908
|
|
||||||
QUERY: update fl set x = x / 2.2;
|
|
||||||
QUERY: select * from fl;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.14
|
|
||||||
-3.14
|
|
||||||
QUERY: create table fl8 (y float8);
|
|
||||||
QUERY: insert into fl8 values ( '3.14'::float8 );
|
|
||||||
QUERY: insert into fl8 values ( '147.0'::float8 );
|
|
||||||
QUERY: insert into fl8 values ( '3.140000001'::float8 );
|
|
||||||
QUERY: insert into fl8 values ( '-3.14'::float8);
|
|
||||||
QUERY: select * from fl8;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y = 3.14;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
3.140000001
|
|
||||||
QUERY: select * from fl8 where y <> 3.14;
|
|
||||||
y
|
|
||||||
------
|
|
||||||
147
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y < 3.14;
|
|
||||||
y
|
|
||||||
------
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y <= 3.14;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
3.140000001
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y > 3.14;
|
|
||||||
y
|
|
||||||
----
|
|
||||||
147
|
|
||||||
QUERY: select * from fl8 where y >= 3.14;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
QUERY: select * from fl8 where y = '3.14';
|
|
||||||
y
|
|
||||||
-----
|
|
||||||
3.14
|
|
||||||
QUERY: select * from fl8 where y <> '3.14';
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y < '3.14';
|
|
||||||
y
|
|
||||||
------
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y <= '3.14';
|
|
||||||
y
|
|
||||||
------
|
|
||||||
3.14
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y > '3.14';
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
QUERY: select * from fl8 where y >= '3.14';
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
QUERY: select * from fl8 where y = '3.14'::float4;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
3.140000001
|
|
||||||
QUERY: select * from fl8 where y <> '3.14'::float4;
|
|
||||||
y
|
|
||||||
------
|
|
||||||
147
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y < '3.14'::float4;
|
|
||||||
y
|
|
||||||
------
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y <= '3.14'::float4;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
3.140000001
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y > '3.14'::float4;
|
|
||||||
y
|
|
||||||
----
|
|
||||||
147
|
|
||||||
QUERY: select * from fl8 where y >= '3.14'::float4;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
QUERY: select * from fl8 where y = '3.14'::float8;
|
|
||||||
y
|
|
||||||
-----
|
|
||||||
3.14
|
|
||||||
QUERY: select * from fl8 where y <> '3.14'::float8;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y < '3.14'::float8;
|
|
||||||
y
|
|
||||||
------
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y <= '3.14'::float8;
|
|
||||||
y
|
|
||||||
------
|
|
||||||
3.14
|
|
||||||
-3.14
|
|
||||||
QUERY: select * from fl8 where y > '3.14'::float8;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
QUERY: select * from fl8 where y >= '3.14'::float8;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
QUERY: update fl8 set y = y + '2.2'::float8;
|
|
||||||
QUERY: select * from fl8;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
5.34
|
|
||||||
149.2
|
|
||||||
5.340000001
|
|
||||||
-0.94
|
|
||||||
QUERY: update fl8 set y = y - '2.2'::float8;
|
|
||||||
QUERY: select * from fl8;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
-3.14
|
|
||||||
QUERY: update fl8 set y = y * '2.2'::float8;
|
|
||||||
QUERY: select * from fl8;
|
|
||||||
y
|
|
||||||
-------------
|
|
||||||
6.908
|
|
||||||
323.4
|
|
||||||
6.9080000022
|
|
||||||
-6.908
|
|
||||||
QUERY: update fl8 set y = y / '2.2'::float8;
|
|
||||||
QUERY: select * from fl8;
|
|
||||||
y
|
|
||||||
------------
|
|
||||||
3.14
|
|
||||||
147
|
|
||||||
3.140000001
|
|
||||||
-3.14
|
|
||||||
QUERY: drop table fl;
|
|
||||||
QUERY: drop table fl8;
|
|
@ -1,262 +0,0 @@
|
|||||||
QUERY: create table G (x int4, y int4, z int4);
|
|
||||||
QUERY: insert into G values (1, 2, 6);
|
|
||||||
QUERY: insert into G values (1, 3, 7);
|
|
||||||
QUERY: insert into G values (1, 3, 8);
|
|
||||||
QUERY: insert into G values (1, 4, 9);
|
|
||||||
QUERY: insert into G values (1, 4, 10);
|
|
||||||
QUERY: insert into G values (1, 4, 11);
|
|
||||||
QUERY: insert into G values (1, 5, 12);
|
|
||||||
QUERY: insert into G values (1, 5, 13);
|
|
||||||
QUERY: select x from G group by x;
|
|
||||||
x
|
|
||||||
--
|
|
||||||
1
|
|
||||||
QUERY: select y from G group by y;
|
|
||||||
y
|
|
||||||
--
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
||||||
5
|
|
||||||
QUERY: select z from G group by z;
|
|
||||||
z
|
|
||||||
---
|
|
||||||
6
|
|
||||||
7
|
|
||||||
8
|
|
||||||
9
|
|
||||||
10
|
|
||||||
11
|
|
||||||
12
|
|
||||||
13
|
|
||||||
QUERY: select x, y from G group by x, y;
|
|
||||||
x y
|
|
||||||
-- --
|
|
||||||
1 2
|
|
||||||
1 3
|
|
||||||
1 4
|
|
||||||
1 5
|
|
||||||
QUERY: select x, y from G group by y, x;
|
|
||||||
x y
|
|
||||||
-- --
|
|
||||||
1 2
|
|
||||||
1 3
|
|
||||||
1 4
|
|
||||||
1 5
|
|
||||||
QUERY: select x, y, z from G group by x, y, z;
|
|
||||||
x y z
|
|
||||||
-- -- ---
|
|
||||||
1 2 6
|
|
||||||
1 3 7
|
|
||||||
1 3 8
|
|
||||||
1 4 9
|
|
||||||
1 4 10
|
|
||||||
1 4 11
|
|
||||||
1 5 12
|
|
||||||
1 5 13
|
|
||||||
QUERY: select count(y) from G group by y;
|
|
||||||
count
|
|
||||||
------
|
|
||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
2
|
|
||||||
QUERY: select x, count(x) from G group by x;
|
|
||||||
x count
|
|
||||||
-- ------
|
|
||||||
1 8
|
|
||||||
QUERY: select y, count(y), sum(G.z) from G group by y;
|
|
||||||
y count sum
|
|
||||||
-- ------ ----
|
|
||||||
2 1 6
|
|
||||||
3 2 15
|
|
||||||
4 3 30
|
|
||||||
5 2 25
|
|
||||||
QUERY: select sum(G.x), sum(G.y), z from G group by z;
|
|
||||||
sum sum z
|
|
||||||
---- ---- ---
|
|
||||||
1 2 6
|
|
||||||
1 3 7
|
|
||||||
1 3 8
|
|
||||||
1 4 9
|
|
||||||
1 4 10
|
|
||||||
1 4 11
|
|
||||||
1 5 12
|
|
||||||
1 5 13
|
|
||||||
QUERY: select y, avg(z) from G group by y;
|
|
||||||
y avg
|
|
||||||
-- ----
|
|
||||||
2 6
|
|
||||||
3 7
|
|
||||||
4 10
|
|
||||||
5 12
|
|
||||||
QUERY: select sum(x) from G group by y;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
2
|
|
||||||
QUERY: select sum(x), sum(z) from G group by y;
|
|
||||||
sum sum
|
|
||||||
---- ----
|
|
||||||
1 6
|
|
||||||
2 15
|
|
||||||
3 30
|
|
||||||
2 25
|
|
||||||
QUERY: select sum(z) from G group by y;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
6
|
|
||||||
15
|
|
||||||
30
|
|
||||||
25
|
|
||||||
QUERY: select sum(G.z)/count(G.z), avg(G.z) from G group by y;
|
|
||||||
?column? avg
|
|
||||||
--------- ----
|
|
||||||
6 6
|
|
||||||
7 7
|
|
||||||
10 10
|
|
||||||
12 12
|
|
||||||
QUERY: select y, count(y) from G where z < 11 group by y;
|
|
||||||
y count
|
|
||||||
-- ------
|
|
||||||
2 1
|
|
||||||
3 2
|
|
||||||
4 2
|
|
||||||
QUERY: select y, count(y) from G where z > 9 group by y;
|
|
||||||
y count
|
|
||||||
-- ------
|
|
||||||
4 2
|
|
||||||
5 2
|
|
||||||
QUERY: select y, count(y) from G where z > 8 and z < 12 group by y;
|
|
||||||
y count
|
|
||||||
-- ------
|
|
||||||
4 3
|
|
||||||
QUERY: select y, count(y) from G where y = 4 group by y;
|
|
||||||
y count
|
|
||||||
-- ------
|
|
||||||
4 3
|
|
||||||
QUERY: select y, count(y) from G where y > 10 group by y;
|
|
||||||
y count
|
|
||||||
-- ------
|
|
||||||
0
|
|
||||||
QUERY: select y, count(y) as c from G group by y order by c;
|
|
||||||
y c
|
|
||||||
-- --
|
|
||||||
2 1
|
|
||||||
5 2
|
|
||||||
3 2
|
|
||||||
4 3
|
|
||||||
QUERY: select y, count(y) as c from G group by y order by c, y;
|
|
||||||
y c
|
|
||||||
-- --
|
|
||||||
2 1
|
|
||||||
3 2
|
|
||||||
5 2
|
|
||||||
4 3
|
|
||||||
QUERY: select y, count(y) as c from G where z > 20 group by y order by c;
|
|
||||||
y c
|
|
||||||
-- --
|
|
||||||
0
|
|
||||||
QUERY: select x, y from G order by y, x;
|
|
||||||
x y
|
|
||||||
-- --
|
|
||||||
1 2
|
|
||||||
1 3
|
|
||||||
1 3
|
|
||||||
1 4
|
|
||||||
1 4
|
|
||||||
1 4
|
|
||||||
1 5
|
|
||||||
1 5
|
|
||||||
QUERY: create table H (a int4, b int4);
|
|
||||||
QUERY: insert into H values (3, 9)
|
|
||||||
insert into H values (4, 13);
|
|
||||||
QUERY: create table F (p int4);
|
|
||||||
QUERY: insert into F values (7)
|
|
||||||
insert into F values (11);
|
|
||||||
QUERY: select y from G, H where G.y = H.a group by y;
|
|
||||||
y
|
|
||||||
--
|
|
||||||
3
|
|
||||||
4
|
|
||||||
QUERY: select sum(b) from G, H where G.y = H.a group by y;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
18
|
|
||||||
39
|
|
||||||
QUERY: select y, count(y), sum(b) from G, H where G.y = H.a group by y;
|
|
||||||
y count sum
|
|
||||||
-- ------ ----
|
|
||||||
3 2 18
|
|
||||||
4 3 39
|
|
||||||
QUERY: select a, sum(x), sum(b) from G, H where G.y = H.a group by a;
|
|
||||||
a sum sum
|
|
||||||
-- ---- ----
|
|
||||||
3 2 18
|
|
||||||
4 3 39
|
|
||||||
QUERY: select y, count(*) from G, H where G.z = H.b group by y;
|
|
||||||
y count
|
|
||||||
-- ------
|
|
||||||
4 1
|
|
||||||
5 1
|
|
||||||
QUERY: select z, sum(y) from G, H, F where G.y = H.a and G.z = F.p group by z;
|
|
||||||
z sum
|
|
||||||
--- ----
|
|
||||||
7 3
|
|
||||||
11 4
|
|
||||||
QUERY: select a, avg(p) from G, H, F where G.y = H.a and G.z = F.p group by a;
|
|
||||||
a avg
|
|
||||||
-- ----
|
|
||||||
3 7
|
|
||||||
4 11
|
|
||||||
QUERY: select sum(x) from G, H where G.y = H.a;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
5
|
|
||||||
QUERY: select sum(y) from G, H where G.y = H.a;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
18
|
|
||||||
QUERY: select sum(a) from G, H where G.y = H.a;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
18
|
|
||||||
QUERY: select sum(b) from G, H where G.y = H.a;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
57
|
|
||||||
QUERY: select count(*) from G group by y;
|
|
||||||
count
|
|
||||||
------
|
|
||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
2
|
|
||||||
QUERY: insert into G (y, z) values (6, 14);
|
|
||||||
QUERY: insert into G (x, z) values (2, 14);
|
|
||||||
QUERY: select count(*) from G;
|
|
||||||
count
|
|
||||||
------
|
|
||||||
10
|
|
||||||
QUERY: select count(x), count(y), count(z) from G;
|
|
||||||
count count count
|
|
||||||
------ ------ ------
|
|
||||||
9 9 10
|
|
||||||
QUERY: select x from G group by x;
|
|
||||||
x
|
|
||||||
--
|
|
||||||
1
|
|
||||||
2
|
|
||||||
|
|
||||||
QUERY: select y, count(*) from G group by y;
|
|
||||||
y count
|
|
||||||
-- ------
|
|
||||||
2 1
|
|
||||||
3 2
|
|
||||||
4 3
|
|
||||||
5 2
|
|
||||||
6 1
|
|
||||||
1
|
|
||||||
QUERY: drop table G, H, F;
|
|
@ -1,18 +0,0 @@
|
|||||||
QUERY: create table G_ERR (x int4, y int4, z int4);
|
|
||||||
QUERY: select x from G_ERR group by y;
|
|
||||||
x
|
|
||||||
--
|
|
||||||
QUERY: select x, sum(z) from G_ERR group by y;
|
|
||||||
WARN:parser: illegal use of aggregates or non-group column in target list
|
|
||||||
QUERY: select x, count(x) from G_ERR;
|
|
||||||
WARN:parser: illegal use of aggregates or non-group column in target list
|
|
||||||
QUERY: select max(count(x)) from G_ERR;
|
|
||||||
WARN:parser: aggregate can only be applied on an attribute
|
|
||||||
QUERY: select x from G_ERR where count(x) = 1;
|
|
||||||
WARN:parser: aggregates not allowed in WHERE clause
|
|
||||||
QUERY: create table H_ERR (a int4, b int4);
|
|
||||||
QUERY: select y, a, count(y), sum(b)
|
|
||||||
from G_ERR, H_ERR
|
|
||||||
where G_ERR.y = H_ERR.a group by y;
|
|
||||||
WARN:parser: illegal use of aggregates or non-group column in target list
|
|
||||||
QUERY: drop table G_ERR, H_ERR;
|
|
@ -1,86 +0,0 @@
|
|||||||
QUERY: create table person (name text, age int4, location point);
|
|
||||||
QUERY: create table man () inherits(person);
|
|
||||||
QUERY: create table emp (salary int4, manager char16) inherits(person);
|
|
||||||
QUERY: create table student (gpa float8) inherits (person);
|
|
||||||
QUERY: create table stud_emp (percent int4) inherits (emp, student);
|
|
||||||
QUERY: create table female_stud_emp () inherits(stud_emp);
|
|
||||||
QUERY: select * from person;
|
|
||||||
name age location
|
|
||||||
----- ---- ---------
|
|
||||||
QUERY: select * from man;
|
|
||||||
name age location
|
|
||||||
----- ---- ---------
|
|
||||||
QUERY: select * from emp;
|
|
||||||
name age location salary manager
|
|
||||||
----- ---- --------- ------- --------
|
|
||||||
QUERY: select * from student;
|
|
||||||
name age location gpa
|
|
||||||
----- ---- --------- ----
|
|
||||||
QUERY: select * from stud_emp;
|
|
||||||
name age location salary manager gpa percent
|
|
||||||
----- ---- --------- ------- -------- ---- --------
|
|
||||||
QUERY: select * from female_stud_emp;
|
|
||||||
name age location salary manager gpa percent
|
|
||||||
----- ---- --------- ------- -------- ---- --------
|
|
||||||
QUERY: insert into person values ('andy', 14, '(1,1)');
|
|
||||||
QUERY: insert into emp values ('betty', 20, '(2, 1)', 1000, 'mandy');
|
|
||||||
QUERY: insert into student values ('cy', 45, '(3, 2)', 1.9);
|
|
||||||
QUERY: insert into stud_emp values ('danny', 19, '(3.3, 4.55)', 400, 'mandy', 3.9);
|
|
||||||
QUERY: insert into man values ('fred', 2, '(0, 0)');
|
|
||||||
QUERY: insert into female_stud_emp values ('gina', 16, '(10, 10)', 500, 'mandy', 3.0);
|
|
||||||
QUERY: select * from person;
|
|
||||||
name age location
|
|
||||||
----- ---- ---------
|
|
||||||
andy 14 (1,1)
|
|
||||||
QUERY: select * from emp;
|
|
||||||
name age location salary manager
|
|
||||||
------ ---- --------- ------- --------
|
|
||||||
betty 20 (2,1) 1000 mandy
|
|
||||||
QUERY: select * from student;
|
|
||||||
name age location gpa
|
|
||||||
----- ---- --------- ----
|
|
||||||
cy 45 (3,2) 1.9
|
|
||||||
QUERY: select * from stud_emp;
|
|
||||||
name age location salary manager gpa percent
|
|
||||||
------ ---- ----------- ------- -------- ---- --------
|
|
||||||
danny 19 (3.3,4.55) 400 mandy 3.9
|
|
||||||
QUERY: select * from man;
|
|
||||||
name age location
|
|
||||||
----- ---- ---------
|
|
||||||
fred 2 (0,0)
|
|
||||||
QUERY: select * from female_stud_emp;
|
|
||||||
name age location salary manager gpa percent
|
|
||||||
----- ---- --------- ------- -------- ---- --------
|
|
||||||
gina 16 (10,10) 500 mandy 3
|
|
||||||
QUERY: select * from person*;
|
|
||||||
name age location
|
|
||||||
------ ---- -----------
|
|
||||||
andy 14 (1,1)
|
|
||||||
fred 2 (0,0)
|
|
||||||
betty 20 (2,1)
|
|
||||||
cy 45 (3,2)
|
|
||||||
danny 19 (3.3,4.55)
|
|
||||||
gina 16 (10,10)
|
|
||||||
QUERY: select * from emp*;
|
|
||||||
name age location salary manager
|
|
||||||
------ ---- ----------- ------- --------
|
|
||||||
betty 20 (2,1) 1000 mandy
|
|
||||||
danny 19 (3.3,4.55) 400 mandy
|
|
||||||
gina 16 (10,10) 500 mandy
|
|
||||||
QUERY: select * from student*;
|
|
||||||
name age location gpa
|
|
||||||
------ ---- ----------- ----
|
|
||||||
cy 45 (3,2) 1.9
|
|
||||||
danny 19 (3.3,4.55) 3.9
|
|
||||||
gina 16 (10,10) 3
|
|
||||||
QUERY: select * from stud_emp*;
|
|
||||||
name age location salary manager gpa percent
|
|
||||||
------ ---- ----------- ------- -------- ---- --------
|
|
||||||
danny 19 (3.3,4.55) 400 mandy 3.9
|
|
||||||
gina 16 (10,10) 500 mandy 3
|
|
||||||
QUERY: drop table female_stud_emp;
|
|
||||||
QUERY: drop table stud_emp;
|
|
||||||
QUERY: drop table student;
|
|
||||||
QUERY: drop table emp;
|
|
||||||
QUERY: drop table man;
|
|
||||||
QUERY: drop table person;
|
|
@ -1,40 +0,0 @@
|
|||||||
QUERY: create table foo (x int4, y int4);
|
|
||||||
QUERY: create table bar (p int4, q int4);
|
|
||||||
QUERY: create table baz (a int4, b int4);
|
|
||||||
QUERY: insert into foo values (1, 1);
|
|
||||||
QUERY: insert into foo values (2, 2);
|
|
||||||
QUERY: insert into bar values (1, 1);
|
|
||||||
QUERY: insert into baz values (1, 1);
|
|
||||||
QUERY: insert into baz values (2, 2);
|
|
||||||
QUERY: select * from foo,bar,baz
|
|
||||||
where foo.x=bar.p and bar.p=baz.a and baz.b=foo.y;
|
|
||||||
x y p q a b
|
|
||||||
-- -- -- -- -- --
|
|
||||||
1 1 1 1 1 1
|
|
||||||
QUERY: select * from foo,bar,baz
|
|
||||||
where foo.y=bar.p and bar.p=baz.a and baz.b=foo.x and foo.y=bar.q;
|
|
||||||
x y p q a b
|
|
||||||
-- -- -- -- -- --
|
|
||||||
1 1 1 1 1 1
|
|
||||||
QUERY: select * from foo,bar,baz
|
|
||||||
where foo.x=bar.q and bar.p=baz.b and baz.b=foo.y and foo.y=bar.q
|
|
||||||
and bar.p=baz.a;
|
|
||||||
x y p q a b
|
|
||||||
-- -- -- -- -- --
|
|
||||||
1 1 1 1 1 1
|
|
||||||
QUERY: select * from foo,bar,baz
|
|
||||||
where foo.y=bar.p and bar.q=baz.b and baz.b=foo.x and foo.x=bar.q
|
|
||||||
and bar.p=baz.a and bar.p=baz.a;
|
|
||||||
x y p q a b
|
|
||||||
-- -- -- -- -- --
|
|
||||||
1 1 1 1 1 1
|
|
||||||
QUERY: select bar.p from foo, bar;
|
|
||||||
p
|
|
||||||
--
|
|
||||||
1
|
|
||||||
1
|
|
||||||
QUERY: select foo.x from foo, bar where foo.x = bar.p;
|
|
||||||
x
|
|
||||||
--
|
|
||||||
1
|
|
||||||
QUERY: drop table foo, bar, baz;
|
|
@ -1,18 +0,0 @@
|
|||||||
QUERY: create operator ##+ (leftarg=int4, rightarg=int4, procedure = int4pl);
|
|
||||||
QUERY: create operator ##+ (rightarg=int4, procedure=int4fac);
|
|
||||||
QUERY: create operator ##+ (leftarg=int4, procedure=int4inc);
|
|
||||||
QUERY: select 4 ##+ 4;
|
|
||||||
?column?
|
|
||||||
---------
|
|
||||||
8
|
|
||||||
QUERY: select ##+ 4;
|
|
||||||
?column?
|
|
||||||
---------
|
|
||||||
24
|
|
||||||
QUERY: select (4 ##+);
|
|
||||||
?column?
|
|
||||||
---------
|
|
||||||
5
|
|
||||||
QUERY: drop operator ##+(int4,int4);
|
|
||||||
QUERY: drop operator ##+(none, int4);
|
|
||||||
QUERY: drop operator ##+(int4, none);
|
|
@ -1,60 +0,0 @@
|
|||||||
QUERY: create table foo (x int4, y int4, z int4);
|
|
||||||
QUERY: create table bar (x int4, y int4, z int4);
|
|
||||||
QUERY: create table baz (a int4, b int4);
|
|
||||||
QUERY: insert into foo values (1, 2, 3);
|
|
||||||
QUERY: insert into foo values (4, 5, 6);
|
|
||||||
QUERY: insert into foo values (7, 8, 9);
|
|
||||||
QUERY: insert into bar values (11, 12, 13);
|
|
||||||
QUERY: insert into bar values (14, 15, 16);
|
|
||||||
QUERY: insert into bar values (17, 18, 19);
|
|
||||||
QUERY: insert into baz values (99, 88);
|
|
||||||
QUERY: insert into baz values (77, 66);
|
|
||||||
QUERY: select * from foo f where f.x = 4;
|
|
||||||
x y z
|
|
||||||
-- -- --
|
|
||||||
4 5 6
|
|
||||||
QUERY: select * from foo f, foo where f.x > foo.x;
|
|
||||||
x y z x y z
|
|
||||||
-- -- -- -- -- --
|
|
||||||
4 5 6 1 2 3
|
|
||||||
7 8 9 1 2 3
|
|
||||||
7 8 9 4 5 6
|
|
||||||
QUERY: select * from foo f, foo where f.x = 1 and foo.z > f.z;
|
|
||||||
x y z x y z
|
|
||||||
-- -- -- -- -- --
|
|
||||||
1 2 3 4 5 6
|
|
||||||
1 2 3 7 8 9
|
|
||||||
QUERY: select y as a, z as b from foo order by a;
|
|
||||||
a b
|
|
||||||
-- --
|
|
||||||
2 3
|
|
||||||
5 6
|
|
||||||
8 9
|
|
||||||
QUERY: select foo.y as a, foo.z as b from foo order by b;
|
|
||||||
a b
|
|
||||||
-- --
|
|
||||||
2 3
|
|
||||||
5 6
|
|
||||||
8 9
|
|
||||||
QUERY: select foo.*, bar.z, baz.* from foo, bar, baz;
|
|
||||||
x y z z a b
|
|
||||||
-- -- -- --- --- ---
|
|
||||||
1 2 3 13 99 88
|
|
||||||
4 5 6 13 99 88
|
|
||||||
7 8 9 13 99 88
|
|
||||||
1 2 3 16 99 88
|
|
||||||
4 5 6 16 99 88
|
|
||||||
7 8 9 16 99 88
|
|
||||||
1 2 3 19 99 88
|
|
||||||
4 5 6 19 99 88
|
|
||||||
7 8 9 19 99 88
|
|
||||||
1 2 3 13 77 66
|
|
||||||
4 5 6 13 77 66
|
|
||||||
7 8 9 13 77 66
|
|
||||||
1 2 3 16 77 66
|
|
||||||
4 5 6 16 77 66
|
|
||||||
7 8 9 16 77 66
|
|
||||||
1 2 3 19 77 66
|
|
||||||
4 5 6 19 77 66
|
|
||||||
7 8 9 19 77 66
|
|
||||||
QUERY: drop table foo, bar, baz;
|
|
@ -1,32 +0,0 @@
|
|||||||
QUERY: create table quoteTBL (f text);
|
|
||||||
QUERY: insert into quoteTBL values ('hello world');
|
|
||||||
QUERY: insert into quoteTBL values ('hello '' world');
|
|
||||||
QUERY: insert into quoteTBL values ('hello \' world');
|
|
||||||
QUERY: insert into quoteTBL values ('hello \\ world');
|
|
||||||
QUERY: insert into quoteTBL values ('hello \t world');
|
|
||||||
QUERY: insert into quoteTBL values ('hello
|
|
||||||
world
|
|
||||||
with
|
|
||||||
newlines
|
|
||||||
');
|
|
||||||
QUERY: insert into quoteTBL values ('hello " world');
|
|
||||||
QUERY: insert into quoteTBL values ('');
|
|
||||||
QUERY: -- bad escape sequence
|
|
||||||
insert into quoteTBL values ('hello \y world');
|
|
||||||
WARN:Bad escape sequence, s[i] = 121
|
|
||||||
QUERY: select * from quoteTBL;
|
|
||||||
f
|
|
||||||
---------------------------
|
|
||||||
hello world
|
|
||||||
hello ' world
|
|
||||||
hello ' world
|
|
||||||
hello \ world
|
|
||||||
hello world
|
|
||||||
hello
|
|
||||||
world
|
|
||||||
with
|
|
||||||
newlines
|
|
||||||
|
|
||||||
hello " world
|
|
||||||
|
|
||||||
QUERY: drop table quoteTBL;
|
|
@ -1,22 +0,0 @@
|
|||||||
QUERY: create table foo (x int4);
|
|
||||||
QUERY: select * from foo;
|
|
||||||
x
|
|
||||||
--
|
|
||||||
QUERY: create table bar (x int4, y float4);
|
|
||||||
QUERY: create rule rule1 as on insert to bar do insert into foo (x) values (new.x);
|
|
||||||
QUERY: insert into bar (x,y) values (10, -10.0);
|
|
||||||
QUERY: insert into bar (x,y) values (20, -20.0);
|
|
||||||
QUERY: insert into bar (x,y) values (30, 3.14159);
|
|
||||||
QUERY: select * from bar;
|
|
||||||
x y
|
|
||||||
--- --------
|
|
||||||
10 -10
|
|
||||||
20 -20
|
|
||||||
30 3.14159
|
|
||||||
QUERY: select * from foo;
|
|
||||||
x
|
|
||||||
---
|
|
||||||
10
|
|
||||||
20
|
|
||||||
30
|
|
||||||
QUERY: drop table foo, bar;
|
|
@ -1,31 +0,0 @@
|
|||||||
QUERY: select 1 as X;
|
|
||||||
X
|
|
||||||
--
|
|
||||||
1
|
|
||||||
QUERY: create table foo (name char16, salary int4);
|
|
||||||
QUERY: insert into foo values ('mike', 15000);
|
|
||||||
QUERY: select * from foo where 2 > 1;
|
|
||||||
name salary
|
|
||||||
----- -------
|
|
||||||
mike 15000
|
|
||||||
QUERY: select * from pg_class where 1=0;
|
|
||||||
relname reltype relowner relam relpages reltuples relexpires relpreserved relhasindex relisshared relkind relarch relnatts relsmgr relkey relkeyop relhasrules relacl
|
|
||||||
-------- -------- --------- ------ --------- ---------- ----------- ------------- ------------ ------------ -------- -------- --------- -------- ------- --------- ------------ -------
|
|
||||||
QUERY: create table bar (x int4);
|
|
||||||
QUERY: insert into bar values (1);
|
|
||||||
QUERY: insert into bar values (2);
|
|
||||||
QUERY: insert into bar values (1);
|
|
||||||
QUERY: select distinct * from bar;
|
|
||||||
x
|
|
||||||
--
|
|
||||||
1
|
|
||||||
2
|
|
||||||
QUERY: select distinct * into table bar2 from bar;
|
|
||||||
QUERY: select distinct * from bar2;
|
|
||||||
x
|
|
||||||
--
|
|
||||||
1
|
|
||||||
2
|
|
||||||
QUERY: drop table foo;
|
|
||||||
QUERY: drop table bar;
|
|
||||||
QUERY: drop table bar2;
|
|
@ -1,229 +0,0 @@
|
|||||||
QUERY: create table s1 (x int4, y int4);
|
|
||||||
QUERY: create table s2 (a int4, b int4, c int4);
|
|
||||||
QUERY: insert into s1 values (1, 3);
|
|
||||||
QUERY: insert into s1 values (2, 3);
|
|
||||||
QUERY: insert into s1 values (2, 1);
|
|
||||||
QUERY: insert into s2 values (1, 3, 9);
|
|
||||||
QUERY: insert into s2 values (1, 4, 9);
|
|
||||||
QUERY: insert into s2 values (3, 4, 7);
|
|
||||||
QUERY: insert into s2 values (3, 5, 8);
|
|
||||||
QUERY: select distinct y from s1;
|
|
||||||
y
|
|
||||||
--
|
|
||||||
1
|
|
||||||
3
|
|
||||||
QUERY: select a, c from s2;
|
|
||||||
a c
|
|
||||||
-- --
|
|
||||||
1 9
|
|
||||||
1 9
|
|
||||||
3 7
|
|
||||||
3 8
|
|
||||||
QUERY: select distinct a, c from s2;
|
|
||||||
a c
|
|
||||||
-- --
|
|
||||||
1 9
|
|
||||||
3 7
|
|
||||||
3 8
|
|
||||||
QUERY: select distinct a, c from s2 order by c;
|
|
||||||
a c
|
|
||||||
-- --
|
|
||||||
3 7
|
|
||||||
3 8
|
|
||||||
1 9
|
|
||||||
QUERY: select b, c from s2 order by c, b;
|
|
||||||
b c
|
|
||||||
-- --
|
|
||||||
4 7
|
|
||||||
5 8
|
|
||||||
3 9
|
|
||||||
4 9
|
|
||||||
QUERY: select x, b, c from s1, s2 order by b;
|
|
||||||
x b c
|
|
||||||
-- -- --
|
|
||||||
2 3 9
|
|
||||||
2 3 9
|
|
||||||
1 3 9
|
|
||||||
2 4 7
|
|
||||||
2 4 7
|
|
||||||
1 4 7
|
|
||||||
2 4 9
|
|
||||||
2 4 9
|
|
||||||
1 4 9
|
|
||||||
2 5 8
|
|
||||||
2 5 8
|
|
||||||
1 5 8
|
|
||||||
QUERY: select distinct a, x, c from s1, s2 order by c, x;
|
|
||||||
a x c
|
|
||||||
-- -- --
|
|
||||||
3 1 7
|
|
||||||
3 2 7
|
|
||||||
3 1 8
|
|
||||||
3 2 8
|
|
||||||
1 1 9
|
|
||||||
1 2 9
|
|
||||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by p;
|
|
||||||
p q r
|
|
||||||
-- -- --
|
|
||||||
1 5 8
|
|
||||||
1 4 7
|
|
||||||
1 4 9
|
|
||||||
1 3 9
|
|
||||||
2 3 9
|
|
||||||
2 3 9
|
|
||||||
2 5 8
|
|
||||||
2 5 8
|
|
||||||
2 4 9
|
|
||||||
2 4 7
|
|
||||||
2 4 9
|
|
||||||
2 4 7
|
|
||||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by q;
|
|
||||||
p q r
|
|
||||||
-- -- --
|
|
||||||
2 3 9
|
|
||||||
2 3 9
|
|
||||||
1 3 9
|
|
||||||
2 4 7
|
|
||||||
2 4 7
|
|
||||||
1 4 7
|
|
||||||
2 4 9
|
|
||||||
2 4 9
|
|
||||||
1 4 9
|
|
||||||
2 5 8
|
|
||||||
2 5 8
|
|
||||||
1 5 8
|
|
||||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by r;
|
|
||||||
p q r
|
|
||||||
-- -- --
|
|
||||||
2 4 7
|
|
||||||
2 4 7
|
|
||||||
1 4 7
|
|
||||||
2 5 8
|
|
||||||
2 5 8
|
|
||||||
1 5 8
|
|
||||||
2 4 9
|
|
||||||
2 4 9
|
|
||||||
1 4 9
|
|
||||||
2 3 9
|
|
||||||
2 3 9
|
|
||||||
1 3 9
|
|
||||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by p, r;
|
|
||||||
p q r
|
|
||||||
-- -- --
|
|
||||||
1 4 7
|
|
||||||
1 5 8
|
|
||||||
1 4 9
|
|
||||||
1 3 9
|
|
||||||
2 4 7
|
|
||||||
2 4 7
|
|
||||||
2 5 8
|
|
||||||
2 5 8
|
|
||||||
2 3 9
|
|
||||||
2 4 9
|
|
||||||
2 3 9
|
|
||||||
2 4 9
|
|
||||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by q, r;
|
|
||||||
p q r
|
|
||||||
-- -- --
|
|
||||||
2 3 9
|
|
||||||
2 3 9
|
|
||||||
1 3 9
|
|
||||||
2 4 7
|
|
||||||
2 4 7
|
|
||||||
1 4 7
|
|
||||||
2 4 9
|
|
||||||
2 4 9
|
|
||||||
1 4 9
|
|
||||||
2 5 8
|
|
||||||
2 5 8
|
|
||||||
1 5 8
|
|
||||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by q, p;
|
|
||||||
p q r
|
|
||||||
-- -- --
|
|
||||||
1 3 9
|
|
||||||
2 3 9
|
|
||||||
2 3 9
|
|
||||||
1 4 9
|
|
||||||
1 4 7
|
|
||||||
2 4 7
|
|
||||||
2 4 7
|
|
||||||
2 4 9
|
|
||||||
2 4 9
|
|
||||||
1 5 8
|
|
||||||
2 5 8
|
|
||||||
2 5 8
|
|
||||||
QUERY: create table s3 (x int4);
|
|
||||||
QUERY: insert into s3 values (3);
|
|
||||||
QUERY: insert into s3 values (4);
|
|
||||||
QUERY: select * from s1, s3 order by x;
|
|
||||||
x y x
|
|
||||||
-- -- --
|
|
||||||
1 3 4
|
|
||||||
1 3 3
|
|
||||||
2 1 3
|
|
||||||
2 3 3
|
|
||||||
2 1 4
|
|
||||||
2 3 4
|
|
||||||
QUERY: select * from s3, s1 order by x;
|
|
||||||
x x y
|
|
||||||
-- -- --
|
|
||||||
3 2 1
|
|
||||||
3 2 3
|
|
||||||
3 1 3
|
|
||||||
4 2 3
|
|
||||||
4 1 3
|
|
||||||
4 2 1
|
|
||||||
QUERY: create table s4 (a int4, b int4, c int4, d int4, e int4, f int4, g int4, h int4, i int4);
|
|
||||||
QUERY: insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 2);
|
|
||||||
QUERY: insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 1);
|
|
||||||
QUERY: insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 3);
|
|
||||||
QUERY: select * from s4 order by a, b, c, d, e, f, g, h;
|
|
||||||
a b c d e f g h i
|
|
||||||
-- -- -- -- -- -- -- -- --
|
|
||||||
1 1 1 1 1 1 1 1 3
|
|
||||||
1 1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1 2
|
|
||||||
QUERY: create table s5 (a int4, b int4);
|
|
||||||
QUERY: insert into s5 values (1, 2);
|
|
||||||
QUERY: insert into s5 values (1, 3);
|
|
||||||
QUERY: insert into s5 values (1, 1);
|
|
||||||
QUERY: insert into s5 values (2, 1);
|
|
||||||
QUERY: insert into s5 values (2, 4);
|
|
||||||
QUERY: insert into s5 values (2, 2);
|
|
||||||
QUERY: select * from s5 order by a using <;
|
|
||||||
a b
|
|
||||||
-- --
|
|
||||||
1 1
|
|
||||||
1 3
|
|
||||||
1 2
|
|
||||||
2 2
|
|
||||||
2 4
|
|
||||||
2 1
|
|
||||||
QUERY: select * from s5 order by a using >;
|
|
||||||
a b
|
|
||||||
-- --
|
|
||||||
2 2
|
|
||||||
2 4
|
|
||||||
2 1
|
|
||||||
1 1
|
|
||||||
1 3
|
|
||||||
1 2
|
|
||||||
QUERY: select * from s5 order by a using >, b using <;
|
|
||||||
a b
|
|
||||||
-- --
|
|
||||||
2 1
|
|
||||||
2 2
|
|
||||||
2 4
|
|
||||||
1 1
|
|
||||||
1 2
|
|
||||||
1 3
|
|
||||||
QUERY: select * from s5 order by a using >, b using >;
|
|
||||||
a b
|
|
||||||
-- --
|
|
||||||
2 4
|
|
||||||
2 2
|
|
||||||
2 1
|
|
||||||
1 3
|
|
||||||
1 2
|
|
||||||
1 1
|
|
||||||
QUERY: drop table s1, s2, s3, s4, s5;
|
|
@ -1,100 +0,0 @@
|
|||||||
QUERY: create table st1 (x int, y integer, z int4);
|
|
||||||
QUERY: insert into st1 values (1);
|
|
||||||
QUERY: insert into st1 values (10);
|
|
||||||
QUERY: select * from st1;
|
|
||||||
x y z
|
|
||||||
--- -- --
|
|
||||||
1
|
|
||||||
10
|
|
||||||
QUERY: create table st2 (x smallint, y int2);
|
|
||||||
QUERY: insert into st2 values (1);
|
|
||||||
QUERY: insert into st2 values (10);
|
|
||||||
QUERY: select * from st2;
|
|
||||||
x y
|
|
||||||
--- --
|
|
||||||
1
|
|
||||||
10
|
|
||||||
QUERY: create table st3 (x float, y real, z float4);
|
|
||||||
QUERY: insert into st3 values (1);
|
|
||||||
QUERY: insert into st3 values (10);
|
|
||||||
QUERY: select * from st3;
|
|
||||||
x y z
|
|
||||||
--- -- --
|
|
||||||
1
|
|
||||||
10
|
|
||||||
QUERY: create table st4 (x float8);
|
|
||||||
QUERY: insert into st4 values (1);
|
|
||||||
QUERY: insert into st4 values (10);
|
|
||||||
QUERY: select * from st4;
|
|
||||||
x
|
|
||||||
---
|
|
||||||
1
|
|
||||||
10
|
|
||||||
QUERY: select max(x) from st1;
|
|
||||||
max
|
|
||||||
----
|
|
||||||
10
|
|
||||||
QUERY: select min(x) from st1;
|
|
||||||
min
|
|
||||||
----
|
|
||||||
1
|
|
||||||
QUERY: select sum(x) from st1;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
11
|
|
||||||
QUERY: select avg(x) from st1;
|
|
||||||
avg
|
|
||||||
----
|
|
||||||
5
|
|
||||||
QUERY: select max(x) from st2;
|
|
||||||
max
|
|
||||||
----
|
|
||||||
10
|
|
||||||
QUERY: select min(x) from st2;
|
|
||||||
min
|
|
||||||
----
|
|
||||||
1
|
|
||||||
QUERY: select sum(x) from st2;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
11
|
|
||||||
QUERY: select avg(x) from st2;
|
|
||||||
avg
|
|
||||||
----
|
|
||||||
5
|
|
||||||
QUERY: select max(x) from st3;
|
|
||||||
max
|
|
||||||
----
|
|
||||||
10
|
|
||||||
QUERY: select min(x) from st3;
|
|
||||||
min
|
|
||||||
----
|
|
||||||
1
|
|
||||||
QUERY: select sum(x) from st3;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
11
|
|
||||||
QUERY: select avg(x) from st3;
|
|
||||||
avg
|
|
||||||
----
|
|
||||||
5.5
|
|
||||||
QUERY: select max(x) from st4;
|
|
||||||
max
|
|
||||||
----
|
|
||||||
10
|
|
||||||
QUERY: select min(x) from st4;
|
|
||||||
min
|
|
||||||
----
|
|
||||||
1
|
|
||||||
QUERY: select sum(x) from st4;
|
|
||||||
sum
|
|
||||||
----
|
|
||||||
11
|
|
||||||
QUERY: select avg(x) from st4;
|
|
||||||
avg
|
|
||||||
----
|
|
||||||
5.5
|
|
||||||
QUERY: drop table st1;
|
|
||||||
QUERY: drop table st2;
|
|
||||||
QUERY: drop table st3;
|
|
||||||
QUERY: drop table st4;
|
|
@ -1,72 +0,0 @@
|
|||||||
QUERY: create table tt (t time);
|
|
||||||
QUERY: insert into tt values ('6:22:19.95');
|
|
||||||
QUERY: insert into tt values ('5:31:19.94');
|
|
||||||
QUERY: insert into tt values ('2:29:1.996');
|
|
||||||
QUERY: insert into tt values ('23:59:59.93');
|
|
||||||
QUERY: insert into tt values ('0:0:0.0');
|
|
||||||
QUERY: insert into tt values ('2:29:1.996');
|
|
||||||
QUERY: select * from tt;
|
|
||||||
t
|
|
||||||
----------------
|
|
||||||
06:22:19.950001
|
|
||||||
05:31:19.940001
|
|
||||||
02:29:01.996000
|
|
||||||
23:59:59.930000
|
|
||||||
00:00:00.000000
|
|
||||||
02:29:01.996000
|
|
||||||
QUERY: select * from tt order by t;
|
|
||||||
t
|
|
||||||
----------------
|
|
||||||
00:00:00.000000
|
|
||||||
02:29:01.996000
|
|
||||||
02:29:01.996000
|
|
||||||
05:31:19.940001
|
|
||||||
06:22:19.950001
|
|
||||||
23:59:59.930000
|
|
||||||
QUERY: select * from tt order by t using >;
|
|
||||||
t
|
|
||||||
----------------
|
|
||||||
23:59:59.930000
|
|
||||||
06:22:19.950001
|
|
||||||
05:31:19.940001
|
|
||||||
02:29:01.996000
|
|
||||||
02:29:01.996000
|
|
||||||
00:00:00.000000
|
|
||||||
QUERY: select * from tt where t = '2:29:1.996';
|
|
||||||
t
|
|
||||||
----------------
|
|
||||||
02:29:01.996000
|
|
||||||
02:29:01.996000
|
|
||||||
QUERY: select * from tt where t <> '2:29:1.996';
|
|
||||||
t
|
|
||||||
----------------
|
|
||||||
06:22:19.950001
|
|
||||||
05:31:19.940001
|
|
||||||
23:59:59.930000
|
|
||||||
00:00:00.000000
|
|
||||||
QUERY: select * from tt where t < '2:29:1.996';
|
|
||||||
t
|
|
||||||
----------------
|
|
||||||
00:00:00.000000
|
|
||||||
QUERY: select * from tt where t <= '2:29:1.996';
|
|
||||||
t
|
|
||||||
----------------
|
|
||||||
02:29:01.996000
|
|
||||||
00:00:00.000000
|
|
||||||
02:29:01.996000
|
|
||||||
QUERY: select * from tt where t > '2:29:1.996';
|
|
||||||
t
|
|
||||||
----------------
|
|
||||||
06:22:19.950001
|
|
||||||
05:31:19.940001
|
|
||||||
23:59:59.930000
|
|
||||||
QUERY: select * from tt where t >= '2:29:1.996';
|
|
||||||
t
|
|
||||||
----------------
|
|
||||||
06:22:19.950001
|
|
||||||
05:31:19.940001
|
|
||||||
02:29:01.996000
|
|
||||||
23:59:59.930000
|
|
||||||
02:29:01.996000
|
|
||||||
QUERY: create index tt_ind on tt using btree (t time_ops);
|
|
||||||
QUERY: drop table tt;
|
|
@ -1,226 +0,0 @@
|
|||||||
QUERY: create table f (x char(5));
|
|
||||||
QUERY: insert into f values ('zoo');
|
|
||||||
QUERY: insert into f values ('a');
|
|
||||||
QUERY: insert into f values ('jet');
|
|
||||||
QUERY: insert into f values ('abc');
|
|
||||||
QUERY: insert into f values ('');
|
|
||||||
QUERY: insert into f values ('a c');
|
|
||||||
QUERY: insert into f values ('abxyzxyz');
|
|
||||||
QUERY: select * from f;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
zoo
|
|
||||||
a
|
|
||||||
jet
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from f where x = 'jet';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
jet
|
|
||||||
QUERY: select * from f where x <> 'jet';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
zoo
|
|
||||||
a
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from f where x < 'jet';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from f where x <= 'jet';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
jet
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from f where x > 'jet';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
zoo
|
|
||||||
QUERY: select * from f where x >= 'jet';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
zoo
|
|
||||||
jet
|
|
||||||
|
|
||||||
QUERY: select * from f where x = 'ab';
|
|
||||||
x
|
|
||||||
--
|
|
||||||
QUERY: select * from f where x <> 'ab';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
zoo
|
|
||||||
a
|
|
||||||
jet
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from f where x < 'ab';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
|
|
||||||
a c
|
|
||||||
QUERY: select * from f where x <= 'ab';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from f where x > 'ab';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
zoo
|
|
||||||
jet
|
|
||||||
abc
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from f where x >= 'ab';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
zoo
|
|
||||||
a
|
|
||||||
jet
|
|
||||||
abc
|
|
||||||
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from f order by x;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
|
|
||||||
a
|
|
||||||
a c
|
|
||||||
abc
|
|
||||||
abxyz
|
|
||||||
jet
|
|
||||||
zoo
|
|
||||||
QUERY: create table ff (x varchar(5));
|
|
||||||
QUERY: insert into ff values ('a');
|
|
||||||
QUERY: insert into ff values ('zoo');
|
|
||||||
QUERY: insert into ff values ('jet');
|
|
||||||
QUERY: insert into ff values ('abc');
|
|
||||||
QUERY: insert into ff values ('');
|
|
||||||
QUERY: insert into ff values ('a c');
|
|
||||||
QUERY: insert into ff values ('abxyzxyz');
|
|
||||||
QUERY: select * from ff;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
zoo
|
|
||||||
jet
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from ff where x = 'jet';
|
|
||||||
x
|
|
||||||
----
|
|
||||||
jet
|
|
||||||
QUERY: select * from ff where x <> 'jet';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
zoo
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from ff where x < 'jet';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from ff where x <= 'jet';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
jet
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from ff where x > 'jet';
|
|
||||||
x
|
|
||||||
----
|
|
||||||
zoo
|
|
||||||
QUERY: select * from ff where x >= 'jet';
|
|
||||||
x
|
|
||||||
----
|
|
||||||
zoo
|
|
||||||
jet
|
|
||||||
|
|
||||||
QUERY: select * from ff where x = 'ab';
|
|
||||||
x
|
|
||||||
--
|
|
||||||
QUERY: select * from ff where x <> 'ab';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
zoo
|
|
||||||
jet
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from ff where x < 'ab';
|
|
||||||
x
|
|
||||||
----
|
|
||||||
a
|
|
||||||
|
|
||||||
a c
|
|
||||||
QUERY: select * from ff where x <= 'ab';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
abc
|
|
||||||
|
|
||||||
a c
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from ff where x > 'ab';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
zoo
|
|
||||||
jet
|
|
||||||
abc
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from ff where x >= 'ab';
|
|
||||||
x
|
|
||||||
------
|
|
||||||
a
|
|
||||||
zoo
|
|
||||||
jet
|
|
||||||
abc
|
|
||||||
|
|
||||||
abxyz
|
|
||||||
QUERY: select * from ff order by x using >;
|
|
||||||
x
|
|
||||||
------
|
|
||||||
zoo
|
|
||||||
jet
|
|
||||||
abxyz
|
|
||||||
abc
|
|
||||||
a c
|
|
||||||
a
|
|
||||||
|
|
||||||
QUERY: create index f_ind on f using btree (x bpchar_ops);
|
|
||||||
QUERY: create index ff_ind on ff using btree (x varchar_ops);
|
|
||||||
QUERY: drop table f;
|
|
||||||
QUERY: drop table ff;
|
|
@ -1,125 +0,0 @@
|
|||||||
QUERY: create table v1 (x int4, y int4, z int4);
|
|
||||||
QUERY: insert into v1 values (1, 2, 3);
|
|
||||||
QUERY: insert into v1 values (1, 3, 4);
|
|
||||||
QUERY: insert into v1 values (1, 4, 5);
|
|
||||||
QUERY: insert into v1 values (1, 2, 6);
|
|
||||||
QUERY: create view vv1 as select x from v1;
|
|
||||||
QUERY: create view vv2 as select y from v1;
|
|
||||||
QUERY: create view vv3 as select z from v1;
|
|
||||||
QUERY: select * from vv1;
|
|
||||||
x
|
|
||||||
--
|
|
||||||
1
|
|
||||||
1
|
|
||||||
1
|
|
||||||
1
|
|
||||||
QUERY: select * from vv2;
|
|
||||||
y
|
|
||||||
--
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
||||||
2
|
|
||||||
QUERY: select * from vv3;
|
|
||||||
z
|
|
||||||
--
|
|
||||||
3
|
|
||||||
4
|
|
||||||
5
|
|
||||||
6
|
|
||||||
QUERY: drop view vv2;
|
|
||||||
QUERY: drop view vv3;
|
|
||||||
QUERY: create view vv as select * from vv1;
|
|
||||||
QUERY: select * from vv;
|
|
||||||
x
|
|
||||||
--
|
|
||||||
1
|
|
||||||
1
|
|
||||||
1
|
|
||||||
1
|
|
||||||
QUERY: create view vv2 as select x from vv;
|
|
||||||
QUERY: select * from vv2;
|
|
||||||
x
|
|
||||||
--
|
|
||||||
1
|
|
||||||
1
|
|
||||||
1
|
|
||||||
1
|
|
||||||
QUERY: drop view vv;
|
|
||||||
QUERY: drop view vv1;
|
|
||||||
QUERY: drop view vv2;
|
|
||||||
QUERY: create view vv1 as select x, z from v1;
|
|
||||||
QUERY: create view vv2 as select y, z from v1;
|
|
||||||
QUERY: create view vv3 as select y, z, x from v1;
|
|
||||||
QUERY: select * from vv1;
|
|
||||||
x z
|
|
||||||
-- --
|
|
||||||
1 3
|
|
||||||
1 4
|
|
||||||
1 5
|
|
||||||
1 6
|
|
||||||
QUERY: select * from vv2;
|
|
||||||
y z
|
|
||||||
-- --
|
|
||||||
2 3
|
|
||||||
3 4
|
|
||||||
4 5
|
|
||||||
2 6
|
|
||||||
QUERY: select * from vv3;
|
|
||||||
y z x
|
|
||||||
-- -- --
|
|
||||||
2 3 1
|
|
||||||
3 4 1
|
|
||||||
4 5 1
|
|
||||||
2 6 1
|
|
||||||
QUERY: drop view vv1;
|
|
||||||
QUERY: drop view vv2;
|
|
||||||
QUERY: drop view vv3;
|
|
||||||
QUERY: create view vv1 as select x as a, z as b, y as c from v1;
|
|
||||||
QUERY: select * from vv1;
|
|
||||||
a b c
|
|
||||||
-- -- --
|
|
||||||
1 3 2
|
|
||||||
1 4 3
|
|
||||||
1 5 4
|
|
||||||
1 6 2
|
|
||||||
QUERY: drop view vv1;
|
|
||||||
QUERY: create view vv1 as select z, 100 as p, x as q from v1;
|
|
||||||
QUERY: select * from vv1;
|
|
||||||
z p q
|
|
||||||
-- ---- --
|
|
||||||
3 100 1
|
|
||||||
4 100 1
|
|
||||||
5 100 1
|
|
||||||
6 100 1
|
|
||||||
QUERY: drop view vv1;
|
|
||||||
QUERY: create view vv1 as select x + y as xy, z from v1;
|
|
||||||
QUERY: select * from vv1;
|
|
||||||
xy z
|
|
||||||
--- --
|
|
||||||
3 3
|
|
||||||
4 4
|
|
||||||
5 5
|
|
||||||
3 6
|
|
||||||
QUERY: drop view vv1;
|
|
||||||
QUERY: create table v2 (a int4);
|
|
||||||
QUERY: insert into v2 values (2);
|
|
||||||
QUERY: insert into v2 values (3);
|
|
||||||
QUERY: create view vv1 as select y, z from v1, v2 where y = a;
|
|
||||||
QUERY: select * from vv1;
|
|
||||||
y z
|
|
||||||
-- --
|
|
||||||
2 6
|
|
||||||
2 3
|
|
||||||
3 4
|
|
||||||
QUERY: drop view vv1;
|
|
||||||
QUERY: create view vv1 as select y - x as yx, z, a from v1, v2 where (x + y) > 3;
|
|
||||||
QUERY: select * from vv1;
|
|
||||||
yx z a
|
|
||||||
--- -- --
|
|
||||||
2 4 2
|
|
||||||
3 5 2
|
|
||||||
2 4 3
|
|
||||||
3 5 3
|
|
||||||
QUERY: drop view vv1;
|
|
||||||
QUERY: drop table v1, v2;
|
|
@ -1,29 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- rules.sql-
|
|
||||||
-- test rules
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: rules.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- test rules creation
|
|
||||||
create table foo (x int4);
|
|
||||||
-- instead rules are not working right now
|
|
||||||
-- create rule rule1 as on select to foo.x do instead update foo set x = 2;
|
|
||||||
-- select rulename, ev_class, ev_type from pg_rewrite;
|
|
||||||
select * from foo;
|
|
||||||
|
|
||||||
create table bar (x int4, y float4);
|
|
||||||
create rule rule1 as on insert to bar do insert into foo (x) values (new.x);
|
|
||||||
insert into bar (x,y) values (10, -10.0);
|
|
||||||
insert into bar (x,y) values (20, -20.0);
|
|
||||||
insert into bar (x,y) values (30, 3.14159);
|
|
||||||
|
|
||||||
select * from bar;
|
|
||||||
select * from foo;
|
|
||||||
drop table foo, bar;
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
#!/bin/csh
|
|
||||||
|
|
||||||
foreach s (*.sql)
|
|
||||||
echo "===> $s";
|
|
||||||
psql -q -e -n $USER < $s > $s.out 2>&1;
|
|
||||||
diff $s.out results/$s.out;
|
|
||||||
end
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- select.sql-
|
|
||||||
-- test select
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: select.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- test Result nodes (constant target list/quals)
|
|
||||||
select 1 as X;
|
|
||||||
create table foo (name char16, salary int4);
|
|
||||||
insert into foo values ('mike', 15000);
|
|
||||||
select * from foo where 2 > 1;
|
|
||||||
select * from pg_class where 1=0;
|
|
||||||
|
|
||||||
-- test select distinct
|
|
||||||
create table bar (x int4);
|
|
||||||
insert into bar values (1);
|
|
||||||
insert into bar values (2);
|
|
||||||
insert into bar values (1);
|
|
||||||
select distinct * from bar;
|
|
||||||
select distinct * into table bar2 from bar;
|
|
||||||
select distinct * from bar2;
|
|
||||||
|
|
||||||
drop table foo;
|
|
||||||
drop table bar;
|
|
||||||
drop table bar2;
|
|
@ -1,57 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- sort.sql-
|
|
||||||
-- test sorting
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: sort.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
create table s1 (x int4, y int4);
|
|
||||||
create table s2 (a int4, b int4, c int4);
|
|
||||||
insert into s1 values (1, 3);
|
|
||||||
insert into s1 values (2, 3);
|
|
||||||
insert into s1 values (2, 1);
|
|
||||||
insert into s2 values (1, 3, 9);
|
|
||||||
insert into s2 values (1, 4, 9);
|
|
||||||
insert into s2 values (3, 4, 7);
|
|
||||||
insert into s2 values (3, 5, 8);
|
|
||||||
select distinct y from s1;
|
|
||||||
select a, c from s2;
|
|
||||||
select distinct a, c from s2;
|
|
||||||
select distinct a, c from s2 order by c;
|
|
||||||
select b, c from s2 order by c, b;
|
|
||||||
select x, b, c from s1, s2 order by b;
|
|
||||||
select distinct a, x, c from s1, s2 order by c, x;
|
|
||||||
select x AS p, b AS q, c AS r from s1, s2 order by p;
|
|
||||||
select x AS p, b AS q, c AS r from s1, s2 order by q;
|
|
||||||
select x AS p, b AS q, c AS r from s1, s2 order by r;
|
|
||||||
select x AS p, b AS q, c AS r from s1, s2 order by p, r;
|
|
||||||
select x AS p, b AS q, c AS r from s1, s2 order by q, r;
|
|
||||||
select x AS p, b AS q, c AS r from s1, s2 order by q, p;
|
|
||||||
create table s3 (x int4);
|
|
||||||
insert into s3 values (3);
|
|
||||||
insert into s3 values (4);
|
|
||||||
select * from s1, s3 order by x;
|
|
||||||
select * from s3, s1 order by x;
|
|
||||||
create table s4 (a int4, b int4, c int4, d int4, e int4, f int4, g int4, h int4, i int4);
|
|
||||||
insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 2);
|
|
||||||
insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 1);
|
|
||||||
insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 3);
|
|
||||||
select * from s4 order by a, b, c, d, e, f, g, h;
|
|
||||||
create table s5 (a int4, b int4);
|
|
||||||
insert into s5 values (1, 2);
|
|
||||||
insert into s5 values (1, 3);
|
|
||||||
insert into s5 values (1, 1);
|
|
||||||
insert into s5 values (2, 1);
|
|
||||||
insert into s5 values (2, 4);
|
|
||||||
insert into s5 values (2, 2);
|
|
||||||
select * from s5 order by a using <;
|
|
||||||
select * from s5 order by a using >;
|
|
||||||
select * from s5 order by a using >, b using <;
|
|
||||||
select * from s5 order by a using >, b using >;
|
|
||||||
|
|
||||||
drop table s1, s2, s3, s4, s5;
|
|
@ -1,57 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- sqlcompat.sql-
|
|
||||||
-- test aliases for SQL basic types and aggregates
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: sqlcompat.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- check aliases for data types
|
|
||||||
create table st1 (x int, y integer, z int4);
|
|
||||||
insert into st1 values (1);
|
|
||||||
insert into st1 values (10);
|
|
||||||
select * from st1;
|
|
||||||
create table st2 (x smallint, y int2);
|
|
||||||
insert into st2 values (1);
|
|
||||||
insert into st2 values (10);
|
|
||||||
select * from st2;
|
|
||||||
create table st3 (x float, y real, z float4);
|
|
||||||
insert into st3 values (1);
|
|
||||||
insert into st3 values (10);
|
|
||||||
select * from st3;
|
|
||||||
|
|
||||||
create table st4 (x float8);
|
|
||||||
insert into st4 values (1);
|
|
||||||
insert into st4 values (10);
|
|
||||||
select * from st4;
|
|
||||||
|
|
||||||
-- check aliases for aggregate names
|
|
||||||
select max(x) from st1;
|
|
||||||
select min(x) from st1;
|
|
||||||
select sum(x) from st1;
|
|
||||||
select avg(x) from st1;
|
|
||||||
|
|
||||||
select max(x) from st2;
|
|
||||||
select min(x) from st2;
|
|
||||||
select sum(x) from st2;
|
|
||||||
select avg(x) from st2;
|
|
||||||
|
|
||||||
select max(x) from st3;
|
|
||||||
select min(x) from st3;
|
|
||||||
select sum(x) from st3;
|
|
||||||
select avg(x) from st3;
|
|
||||||
|
|
||||||
select max(x) from st4;
|
|
||||||
select min(x) from st4;
|
|
||||||
select sum(x) from st4;
|
|
||||||
select avg(x) from st4;
|
|
||||||
|
|
||||||
drop table st1;
|
|
||||||
drop table st2;
|
|
||||||
drop table st3;
|
|
||||||
drop table st4;
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- time.sql-
|
|
||||||
-- test TIME adt
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: time.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
create table tt (t time);
|
|
||||||
insert into tt values ('6:22:19.95');
|
|
||||||
insert into tt values ('5:31:19.94');
|
|
||||||
insert into tt values ('2:29:1.996');
|
|
||||||
insert into tt values ('23:59:59.93');
|
|
||||||
insert into tt values ('0:0:0.0');
|
|
||||||
insert into tt values ('2:29:1.996');
|
|
||||||
select * from tt;
|
|
||||||
select * from tt order by t;
|
|
||||||
select * from tt order by t using >;
|
|
||||||
select * from tt where t = '2:29:1.996';
|
|
||||||
select * from tt where t <> '2:29:1.996';
|
|
||||||
select * from tt where t < '2:29:1.996';
|
|
||||||
select * from tt where t <= '2:29:1.996';
|
|
||||||
select * from tt where t > '2:29:1.996';
|
|
||||||
select * from tt where t >= '2:29:1.996';
|
|
||||||
create index tt_ind on tt using btree (t time_ops);
|
|
||||||
drop table tt;
|
|
@ -1,64 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- varchar.sql-
|
|
||||||
-- test CHAR() and VARCHAR() adts
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: varchar.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- test char(): insert w/ boundary cases
|
|
||||||
create table f (x char(5));
|
|
||||||
insert into f values ('zoo');
|
|
||||||
insert into f values ('a');
|
|
||||||
insert into f values ('jet');
|
|
||||||
insert into f values ('abc');
|
|
||||||
insert into f values ('');
|
|
||||||
insert into f values ('a c');
|
|
||||||
insert into f values ('abxyzxyz');
|
|
||||||
select * from f;
|
|
||||||
select * from f where x = 'jet';
|
|
||||||
select * from f where x <> 'jet';
|
|
||||||
select * from f where x < 'jet';
|
|
||||||
select * from f where x <= 'jet';
|
|
||||||
select * from f where x > 'jet';
|
|
||||||
select * from f where x >= 'jet';
|
|
||||||
select * from f where x = 'ab';
|
|
||||||
select * from f where x <> 'ab';
|
|
||||||
select * from f where x < 'ab';
|
|
||||||
select * from f where x <= 'ab';
|
|
||||||
select * from f where x > 'ab';
|
|
||||||
select * from f where x >= 'ab';
|
|
||||||
select * from f order by x;
|
|
||||||
-- test varchar(): insert w/ boundary cases
|
|
||||||
create table ff (x varchar(5));
|
|
||||||
insert into ff values ('a');
|
|
||||||
insert into ff values ('zoo');
|
|
||||||
insert into ff values ('jet');
|
|
||||||
insert into ff values ('abc');
|
|
||||||
insert into ff values ('');
|
|
||||||
insert into ff values ('a c');
|
|
||||||
insert into ff values ('abxyzxyz');
|
|
||||||
select * from ff;
|
|
||||||
select * from ff where x = 'jet';
|
|
||||||
select * from ff where x <> 'jet';
|
|
||||||
select * from ff where x < 'jet';
|
|
||||||
select * from ff where x <= 'jet';
|
|
||||||
select * from ff where x > 'jet';
|
|
||||||
select * from ff where x >= 'jet';
|
|
||||||
select * from ff where x = 'ab';
|
|
||||||
select * from ff where x <> 'ab';
|
|
||||||
select * from ff where x < 'ab';
|
|
||||||
select * from ff where x <= 'ab';
|
|
||||||
select * from ff where x > 'ab';
|
|
||||||
select * from ff where x >= 'ab';
|
|
||||||
select * from ff order by x using >;
|
|
||||||
|
|
||||||
create index f_ind on f using btree (x bpchar_ops);
|
|
||||||
create index ff_ind on ff using btree (x varchar_ops);
|
|
||||||
|
|
||||||
drop table f;
|
|
||||||
drop table ff;
|
|
@ -1,77 +0,0 @@
|
|||||||
---------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- views.sql-
|
|
||||||
-- test views queries
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994-5, Regents of the University of California
|
|
||||||
--
|
|
||||||
-- $Id: views.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
|
||||||
--
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- create a real table first
|
|
||||||
create table v1 (x int4, y int4, z int4);
|
|
||||||
insert into v1 values (1, 2, 3);
|
|
||||||
insert into v1 values (1, 3, 4);
|
|
||||||
insert into v1 values (1, 4, 5);
|
|
||||||
insert into v1 values (1, 2, 6);
|
|
||||||
|
|
||||||
-- create views for selecting single column
|
|
||||||
create view vv1 as select x from v1;
|
|
||||||
create view vv2 as select y from v1;
|
|
||||||
create view vv3 as select z from v1;
|
|
||||||
select * from vv1;
|
|
||||||
select * from vv2;
|
|
||||||
select * from vv3;
|
|
||||||
drop view vv2;
|
|
||||||
drop view vv3;
|
|
||||||
|
|
||||||
-- create views for selecting column(s) from another view
|
|
||||||
create view vv as select * from vv1;
|
|
||||||
select * from vv;
|
|
||||||
|
|
||||||
create view vv2 as select x from vv;
|
|
||||||
select * from vv2;
|
|
||||||
drop view vv;
|
|
||||||
drop view vv1;
|
|
||||||
drop view vv2;
|
|
||||||
|
|
||||||
-- create views for selecting multiple columns
|
|
||||||
create view vv1 as select x, z from v1;
|
|
||||||
create view vv2 as select y, z from v1;
|
|
||||||
create view vv3 as select y, z, x from v1;
|
|
||||||
select * from vv1;
|
|
||||||
select * from vv2;
|
|
||||||
select * from vv3;
|
|
||||||
drop view vv1;
|
|
||||||
drop view vv2;
|
|
||||||
drop view vv3;
|
|
||||||
|
|
||||||
-- create views with expressions
|
|
||||||
create view vv1 as select x as a, z as b, y as c from v1;
|
|
||||||
select * from vv1;
|
|
||||||
drop view vv1;
|
|
||||||
|
|
||||||
create view vv1 as select z, 100 as p, x as q from v1;
|
|
||||||
select * from vv1;
|
|
||||||
drop view vv1;
|
|
||||||
|
|
||||||
create view vv1 as select x + y as xy, z from v1;
|
|
||||||
select * from vv1;
|
|
||||||
drop view vv1;
|
|
||||||
|
|
||||||
-- create views of joins
|
|
||||||
create table v2 (a int4);
|
|
||||||
insert into v2 values (2);
|
|
||||||
insert into v2 values (3);
|
|
||||||
|
|
||||||
create view vv1 as select y, z from v1, v2 where y = a;
|
|
||||||
select * from vv1;
|
|
||||||
drop view vv1;
|
|
||||||
|
|
||||||
create view vv1 as select y - x as yx, z, a from v1, v2 where (x + y) > 3;
|
|
||||||
select * from vv1;
|
|
||||||
drop view vv1;
|
|
||||||
|
|
||||||
drop table v1, v2;
|
|
Reference in New Issue
Block a user