postgres=# \c rb1;
You are now connected to database "rb1" as user "postgres".
rb1=# create schema data;
CREATE SCHEMA
rb1=# alter schema data owner to dani;
ALTER SCHEMA
rb1=# \q
administrator@administrator-desktop:~$ psql rb1 dani
psql.bin (9.2.4)
Type "help" for help.
rb1=> show search_path ;
search_path
----------------
"$user",public
(1 row)
rb1=> set search_path to data;
SET
rb1=> show search_path ;
search_path
-------------
data
(1 row)
rb1=> create table data.product (product_id char(3),product_name varchar(50));
CREATE TABLE
rb1=> \d public.product;
Table "public.product"
Column | Type | Modifiers
--------------+-----------------------+-----------
product_id | character(3) | not null
product_name | character varying(30) | not null
Indexes:
"product_pkey" PRIMARY KEY, btree (product_id)
Referenced by:
TABLE "public.price_product" CONSTRAINT "price_product_product_id_fkey" FOREIGN KEY (product_id) REFERENCES public.product(product_id)
Triggers:
del_data AFTER DELETE ON public.product FOR EACH ROW EXECUTE PROCEDURE public.del_product()
ins_data AFTER INSERT ON public.product FOR EACH ROW EXECUTE PROCEDURE public.ins_product()
up_data AFTER UPDATE ON public.product FOR EACH ROW EXECUTE PROCEDURE public.up_product()
rb1=> \d data.product;
Table "data.product"
Column | Type | Modifiers
--------------+-----------------------+-----------
product_id | character(3) |
product_name | character varying(50) |
rb1=> insert into data.product values ('002','mouse 111');
INSERT 0 1
rb1=> select *from data.product;
product_id | product_name
------------+--------------
002 | mouse 111
(1 row)
latihan
administrator@administrator-desktop:~$ psql
psql.bin (9.2.4)
Type "help" for help.
postgres=# \c rb1
You are now connected to database "rb1" as user "postgres".
rb1=# create schema mydata;
CREATE SCHEMA
rb1=# alter schema mydata owner to dani;
ALTER SCHEMA
rb1=# show search_path ;
search_path
----------------
"$user",public
(1 row)
rb1=# set search_path to mydata;
SET
rb1=# show search_path ;
search_path
-------------
mydata
(1 row)
rb1=# create table mydata.price_product(product_id char(3),price int,stock int,date date);
CREATE TABLE
rb1=# \d public.price_product;
Table "public.price_product"
Column | Type | Modifiers
------------+--------------+-----------
product_id | character(3) |
price | integer |
stock | integer |
date | date |
Foreign-key constraints:
"price_product_product_id_fkey" FOREIGN KEY (product_id) REFERENCES public.product(product_id)
Triggers:
delete_data AFTER INSERT ON public.price_product FOR EACH ROW EXECUTE PROCEDURE public.delete_price()
insert_data AFTER INSERT ON public.price_product FOR EACH ROW EXECUTE PROCEDURE public.insert_price()
update_data AFTER INSERT ON public.price_product FOR EACH ROW EXECUTE PROCEDURE public.update_price()
rb1=# \d mydata.price_product ;
Table "mydata.price_product"
Column | Type | Modifiers
------------+--------------+-----------
product_id | character(3) |
price | integer |
stock | integer |
date | date |
\d: extra argument ";" ignored
rb1=# insert into mydata.price_product values ('001',100000,50,'2012-09-21');
INSERT 0 1
rb1=# insert into mydata.price_product values ('002',200000,90,'2012-09-24');
INSERT 0 1
rb1=# insert into mydata.price_product values ('003',400000,40,'2012-12-24');
INSERT 0 1
rb1=# insert into mydata.price_product values ('004',300000,70,'2012-02-14');
INSERT 0 1
rb1=# insert into mydata.price_product values ('005',900000,10,'2012-05-24');
INSERT 0 1
rb1=# select * from mydata.price_product ;
product_id | price | stock | date
------------+--------+-------+------------
001 | 100000 | 50 | 2012-09-21
002 | 200000 | 90 | 2012-09-24
003 | 400000 | 40 | 2012-12-24
004 | 300000 | 70 | 2012-02-14
005 | 900000 | 10 | 2012-05-24
(5 rows)