# systemctl status postgresql.service
# netstat -na | grep 5432
# ps ax | grep postgres
# pgrep -l | grep postgres
If all of these look OK, then the server is probably running.
# systemctl status postgresql.service
# netstat -na | grep 5432
# ps ax | grep postgres
# pgrep -l | grep postgres
psql, the "terminal-based front-end to PostgreSQL". # su - postgres
postgres@pantograf:~> psql
psql (9.1.6)
Type "help" for help.
postgres=# \d
No relations found.
postgres=# \h create table
postgres=# CREATE TABLE foobar (foo integer);
CREATE TABLE
postgres=# INSERT INTO foobar VALUES (257);
INSERT 0 1
postgres=# \d
List of relations
Schema | Name | Type | Owner
--------+--------+-------+----------
public | foobar | table | postgres
(1 row)
postgres=# \d foobar
Table "public.foobar"
Column | Type | Modifiers
--------+---------+-----------
foo | integer |
postgres=#
postgres=# drop table foobar; DROP TABLE postgres=# \d No relations found. postgres=#
postgres=# CREATE DATABASE testdb; CREATE DATABASE postgres=# \c testdb; You are now connected to database "testdb" as user "postgres". testdb=#
testdb=# CREATE TABLE foobar (foo text);
CREATE TABLE
testdb=# \d foobar
Table "public.foobar"
Column | Type | Modifiers
--------+------+-----------
foo | text |
testdb=# INSERT INTO foobar VALUES ("Carpe diem");
ERROR: column "Carpe diem" does not exist
LINE 1: INSERT INTO foobar VALUES ("Carpe diem");
testdb=# INSERT INTO foobar VALUES ('Carpe diem');
INSERT 0 1
testdb=# SELECT * FROM foobar;
foo
------------
Carpe diem
(1 row)
testdb=#
psql responds:testdb=# INSERT INTO foobar VALUES ('Now's the time');
testdb'# ^C
testdb=#
testdb=# INSERT INTO foobar VALUES ('Now\'s the time');
testdb'# ^C
testdb=#
backslash_quote (enum)
This controls whether a quote mark can be represented by \' in a
string literal. The preferred, SQL-standard way to represent a quote
mark is by doubling it ('') but PostgreSQL has historically also
accepted \'. However, use of \' creates security risks because in some
client character set encodings, there are multibyte characters in which
the last byte is numerically equivalent to ASCII \. If client-side code
does escaping incorrectly then a SQL-injection attack is possible. This
risk can be prevented by making the server reject queries in which a
quote mark appears to be escaped by a backslash.
testdb=# INSERT INTO foobar VALUES ('Now''s the time');
INSERT 0 1
testdb=# SELECT * FROM foobar WHERE foo = 'Now''s the time';
foo
----------------
Now's the time
(1 row)
LIKE keyword is used for pattern matching. '%' matches any number of any character, while '_' matches any single character:testdb=# SELECT * FROM foobar WHERE foo LIKE 'Now''s%';
foo
----------------
Now's the time
(1 row)
testdb=# SELECT * FROM foobar WHERE foo LIKE 'Now_s the time';
foo
----------------
Now's the time
(1 row)
testdb=#
YOUR_SEARCH_TERMS site:http://www.postgresql.org/docs/9.1
# zypper install perl-DBI perl-DBD-Pg Loading repository data... [output cropped]