PostgreSQL
INSTALL Redhat/Centos
# yum install postgresql postgresql-contrib postgresql-server -y
# postgresql-setup initdb
Initializing database ... OK
# vi /var/lib/pgsql/data/pg_hba.conf
82 host all all 127.0.0.1/32 ident <-change to md5
84 host all all ::1/128 ident <-change to md5
# systemctl start postgresql
# systemctl enable postgresql
# systemctl status postgresql
CREATE DB
From linux prompt (Server KL-Test)
$ su - postgres
Pwd: postgres
$ cd /usr/lib/postgresql/9.5/bin (ubuntu only)
createdb dbphone
ENTER SQL
$ psql dbphone
CREATE TABLE
# \l = list databases
# create table tphone (id int, name varchar(25),phone varchar(15));
# \d = display tables
INSERT DATA
dbphone=# insert into tphone values(1,'Romeo','019-3836031');
INSERT 0 1
DISPLAY DATA
dbphone=# select * from tphone;
id | name | phone
----+-------+-------------
1 | Romeo | 019-3836031
(1 row)
OTHER NOTES
\c dbphone --connect to db
\q -- quit sql
\d tphone --describe table design
# alter table tphone add email varchar(15);
Network connection info
dbphone=# \conninfo
You are connected to database "dbphone" as user "mzadmin" via socket in "/var/run/postgresql" at port "5432".
# yum install postgresql postgresql-contrib postgresql-server -y
# postgresql-setup initdb
Initializing database ... OK
# vi /var/lib/pgsql/data/pg_hba.conf
82 host all all 127.0.0.1/32 ident <-change to md5
84 host all all ::1/128 ident <-change to md5
# systemctl start postgresql
# systemctl enable postgresql
# systemctl status postgresql
CREATE DB
From linux prompt (Server KL-Test)
$ su - postgres
Pwd: postgres
$ cd /usr/lib/postgresql/9.5/bin (ubuntu only)
createdb dbphone
ENTER SQL
$ psql dbphone
CREATE TABLE
# \l = list databases
# create table tphone (id int, name varchar(25),phone varchar(15));
# \d = display tables
INSERT DATA
dbphone=# insert into tphone values(1,'Romeo','019-3836031');
INSERT 0 1
DISPLAY DATA
dbphone=# select * from tphone;
id | name | phone
----+-------+-------------
1 | Romeo | 019-3836031
(1 row)
OTHER NOTES
\c dbphone --connect to db
\q -- quit sql
\d tphone --describe table design
# alter table tphone add email varchar(15);
Network connection info
dbphone=# \conninfo
You are connected to database "dbphone" as user "mzadmin" via socket in "/var/run/postgresql" at port "5432".
1 Comments:
\d+ --> show table size (mb)
Post a Comment
<< Home