alter_co_tables.sql 2.4 KB
Newer Older
1 2 3 4
\c gptest;

-- start_ignore
DROP TABLE if exists sto_alt_co1;
5
set time zone PST8PDT;
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
-- end_ignore

CREATE TABLE sto_alt_co1(
          text_col text default 'remove it',
          bigint_col bigint,
          char_vary_col character varying(30),
          numeric_col numeric,
          int_col int4 NOT NULL,
          float_col float4,
          int_array_col int[],
          before_rename_col int4,
          change_datatype_col numeric,
          a_ts_without timestamp without time zone,
          b_ts_with timestamp with time zone,
          date_column date,
          col_set_default numeric) with(appendonly=true,orientation=column) DISTRIBUTED RANDOMLY;

insert into sto_alt_co1 values ('0_zero', 0, '0_zero', 0, 0, 0, '{0}', 0, 0, '2004-10-19 10:23:54', '2004-10-19 10:23:54+02', '1-1-2000',0);
insert into sto_alt_co1 values ('1_zero', 1, '1_zero', 1, 1, 1, '{1}', 1, 1, '2005-10-19 10:23:54', '2005-10-19 10:23:54+02', '1-1-2001',1);
insert into sto_alt_co1 values ('2_zero', 2, '2_zero', 2, 2, 2, '{2}', 2, 2, '2006-10-19 10:23:54', '2006-10-19 10:23:54+02', '1-1-2002',2);

-- start_ignore
Drop table if exists sto_alt_co3;
-- end_ignore
Create table sto_alt_co3 with(appendonly=true,orientation=column) as select * from sto_alt_co1;

-- Alter table inherit tables
-- start_ignore
Drop table if exists sto_co_parent cascade;
-- end_ignore

CREATE TABLE sto_co_parent (
  text_col text,
  bigint_col bigint,
  char_vary_col character varying(30),
  numeric_col numeric
  ) with(appendonly=true,orientation=column) DISTRIBUTED RANDOMLY;

insert into sto_co_parent values ('0_zero', 0, '0_zero', 0);

-- start_ignore
Drop table if exists sto_alt_co2;
-- end_ignore

CREATE TABLE sto_alt_co2(
  text_col text,
  bigint_col bigint,
  char_vary_col character varying(30),
  numeric_col numeric
  ) with(appendonly=true,orientation=column) DISTRIBUTED RANDOMLY;
insert into sto_alt_co2 values ('1_zero', 1, '1_zero', 1);

-- Alter column  set statistics
Alter table sto_alt_co3  alter column before_rename_col set statistics 3;

-- Alter table SET without cluster
Alter table sto_alt_co3 set without cluster;

--Alter table SET without OIDs
Alter table sto_alt_co3 SET without oids;

--Alter table to a new owner
-- start_ignore
Drop table if exists sto_alt_co4 ;
Drop role if exists co_user1;
-- end_ignore

Create role co_user1;
Create table sto_alt_co4 with(appendonly=true, orientation=column) as select * from sto_alt_co3;