Server
[localhost]: localhost
Database [postgres]: product
Port [5432]:
Username [postgres]: ikhwani
Password for user ikhwani:
psql (9.3.0)
WARNING: Console code page (850)
differs from Windows code page (1252)
8-bit characters might not
work correctly. See psql reference
page "Notes for
Windows users" for details.
Type "help" for help.
product=> psql
product-> \c product;
WARNING: Console code page (850)
differs from Windows code page (1252)
8-bit characters might not
work correctly. See psql reference
page "Notes for
Windows users" for details.
You are now connected to database
"product" as user "ikhwani".
product-> create schema data;
^
product=> create schema data;
CREATE SCHEMA
product=> alter schema data owner
to ikhwani;
ALTER SCHEMA
product=> show search_path;
search_path
----------------
"$user",public
(1 row)
product=> set search_path to
data;
SET
product=> show search_path;
search_path
-------------
data
(1 row)
product=> create table
data.product (product_id char(3), product_name varchar (50));
CREATE TABLE
product=> \d public.product;
Table "public.product"
Column | Type
| Modifiers
--------------+-----------------------+-----------
product_id | character(8)
| 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)
product=> \d data.product;
Table "data.product"
Column | Type
| Modifiers
--------------+-----------------------+-----------
product_id | character(3)
|
product_name | character
varying(50) |
product=> insert into
data.product values('002','Mouse 111');
INSERT 0 1
product=> select * from
data.product;
product_id | product_name
------------+--------------
002 | Mouse 111
(1 row)
NOMOR 1
product=> create schema mydata;
CREATE SCHEMA
product=> alter schema mydata
owner to ikhwani;
ALTER SCHEMA
product=> show search_path;
search_path
----------------
"$user",public
(1 row)
product=> set search_path to
mydata;
SET
product=> show search_path;
search_path
-------------
mydata
(1 row)
NOMOR 2
create table price_product
(product_id char(3), price int, stock int, date date);
CREATE TABLE
NOMOR 3
product=> create table
price_product (product_id char(3), price int, stock int, date date);
CREATE TABLE
product=> insert into
price_product values ('001','100000','10','10-10-2010');
INSERT 0 1
product=> insert into
price_product values ('002','240000','5','12-10-2010');
INSERT 0 1
product=> insert into
price_product values ('003','50000','50','12-10-2010');
INSERT 0 1
product=> insert into
price_product values ('004','500000','2','12-11-2010');
INSERT 0 1
product=> insert into
price_product values ('005','1000000','1','17-11-2010');
INSERT 0 1
^
product=> select * from
price_product;
product_id | price | stock |
date
------------+---------+-------+------------
001 | 100000 | 10 |
2010-10-10
002 | 240000 | 5 |
2010-10-12
003 | 50000 | 50 |
2010-10-12
004 | 500000 | 2 |
2010-11-12
005 | 1000000 | 1 |
2010-11-17
(5 rows)
product=>


