Database JUNKY

MySQL,MariaDBを中心としたブログです

EnterpriseDB(PostgreSQL Plus)のメモ -- コマンド

コンパイルしてインストールするのが、おっくうなので、PostgreSQLを利用する場合は、基本、Enterprisedb(EDB)を利用します。 Linuxでのインストールは、X-Windowが必要ですが、コンパイルするよりまし(笑)

とまあ、インストールは楽なのですが、コマンドは毎回毎回ですが、忘れます。ヘルプを見ればわかるのですが、ここは基本の個人のメモ帳扱いなので、 ぱっとみてできるようにヘルプファイルをコピーしております。

[psqlのコマンド] # /opt/PostgresPlus/9.0SS/bin/psql --help ででます。

psql is the PostgreSQL interactive terminal.

Usage:
  psql [OPTION]... [DBNAME [USERNAME]]

General options:
  -c, --command=COMMAND    run only single command (SQL or internal) and exit
  -d, --dbname=DBNAME      database name to connect to (default: "root")
  -f, --file=FILENAME      execute commands from file, then exit
  -l, --list               list available databases, then exit
  -v, --set=, --variable=NAME=VALUE
                           set psql variable NAME to VALUE
  -X, --no-psqlrc          do not read startup file (~/.psqlrc)
  -1 ("one"), --single-transaction
                           execute command file as a single transaction
  --help                   show this help, then exit
  --version                output version information, then exit

Input and output options:
  -a, --echo-all           echo all input from script
  -e, --echo-queries       echo commands sent to server
  -E, --echo-hidden        display queries that internal commands generate
  -L, --log-file=FILENAME  send session log to file
  -n, --no-readline        disable enhanced command line editing (readline)
  -o, --output=FILENAME    send query results to file (or |pipe)
  -q, --quiet              run quietly (no messages, only query output)
  -s, --single-step        single-step mode (confirm each query)
  -S, --single-line        single-line mode (end of line terminates SQL command)

Output format options:
  -A, --no-align           unaligned table output mode
  -F, --field-separator=STRING
                           set field separator (default: "|")
  -H, --html               HTML table output mode
  -P, --pset=VAR[=ARG]     set printing option VAR to ARG (see \pset command)
  -R, --record-separator=STRING
                           set record separator (default: newline)
  -t, --tuples-only        print rows only
  -T, --table-attr=TEXT    set HTML table tag attributes (e.g., width, border)
  -x, --expanded           turn on expanded table output

Connection options:
  -h, --host=HOSTNAME      database server host or socket directory (default: "local socket")
  -p, --port=PORT          database server port (default: "5432")
  -U, --username=USERNAME  database user name (default: "root")
  -w, --no-password        never prompt for password
  -W, --password           force password prompt (should happen automatically)

For more information, type "\?" (for internal commands) or "\help" (for SQL
commands) from within psql, or consult the psql section in the PostgreSQL
documentation.

Report bugs to <pgsql-bugs@postgresql.org>.

[postgresql]内でのコマンド一覧

# /opt/PostgresPlus/9.0SS/bin/psql -U postgres -c "\h"
Password for user postgres: 
Available help:
  ABORT                            COMMIT                           DELETE                           FETCH
  ALTER AGGREGATE                  COMMIT PREPARED                  DISCARD                          GRANT
  ALTER CONVERSION                 COPY                             DO                               INSERT
  ALTER DATABASE                   CREATE AGGREGATE                 DROP AGGREGATE                   LISTEN
  ALTER DEFAULT PRIVILEGES         CREATE CAST                      DROP CAST                        LOAD
  ALTER DOMAIN                     CREATE CONSTRAINT TRIGGER        DROP CONVERSION                  LOCK
  ALTER FOREIGN DATA WRAPPER       CREATE CONVERSION                DROP DATABASE                    MOVE
  ALTER FUNCTION                   CREATE DATABASE                  DROP DOMAIN                      NOTIFY
  ALTER GROUP                      CREATE DOMAIN                    DROP FOREIGN DATA WRAPPER        PREPARE
  ALTER INDEX                      CREATE FOREIGN DATA WRAPPER      DROP FUNCTION                    PREPARE TRANSACTION
  ALTER LANGUAGE                   CREATE FUNCTION                  DROP GROUP                       REASSIGN OWNED
  ALTER LARGE OBJECT               CREATE GROUP                     DROP INDEX                       REINDEX
  ALTER OPERATOR                   CREATE INDEX                     DROP LANGUAGE                    RELEASE SAVEPOINT
  ALTER OPERATOR CLASS             CREATE LANGUAGE                  DROP OPERATOR                    RESET
  ALTER OPERATOR FAMILY            CREATE OPERATOR                  DROP OPERATOR CLASS              REVOKE
  ALTER ROLE                       CREATE OPERATOR CLASS            DROP OPERATOR FAMILY             ROLLBACK
  ALTER SCHEMA                     CREATE OPERATOR FAMILY           DROP OWNED                       ROLLBACK PREPARED
  ALTER SEQUENCE                   CREATE ROLE                      DROP ROLE                        ROLLBACK TO SAVEPOINT
  ALTER SERVER                     CREATE RULE                      DROP RULE                        SAVEPOINT
  ALTER TABLE                      CREATE SCHEMA                    DROP SCHEMA                      SELECT
  ALTER TABLESPACE                 CREATE SEQUENCE                  DROP SEQUENCE                    SELECT INTO
  ALTER TEXT SEARCH CONFIGURATION  CREATE SERVER                    DROP SERVER                      SET
  ALTER TEXT SEARCH DICTIONARY     CREATE TABLE                     DROP TABLE                       SET CONSTRAINTS
  ALTER TEXT SEARCH PARSER         CREATE TABLE AS                  DROP TABLESPACE                  SET ROLE
  ALTER TEXT SEARCH TEMPLATE       CREATE TABLESPACE                DROP TEXT SEARCH CONFIGURATION   SET SESSION AUTHORIZATION
  ALTER TRIGGER                    CREATE TEXT SEARCH CONFIGURATION DROP TEXT SEARCH DICTIONARY      SET TRANSACTION
  ALTER TYPE                       CREATE TEXT SEARCH DICTIONARY    DROP TEXT SEARCH PARSER          SHOW
  ALTER USER                       CREATE TEXT SEARCH PARSER        DROP TEXT SEARCH TEMPLATE        START TRANSACTION
  ALTER USER MAPPING               CREATE TEXT SEARCH TEMPLATE      DROP TRIGGER                     TABLE
  ALTER VIEW                       CREATE TRIGGER                   DROP TYPE                        TRUNCATE
  ANALYZE                          CREATE TYPE                      DROP USER                        UNLISTEN
  BEGIN                            CREATE USER                      DROP USER MAPPING                UPDATE
  CHECKPOINT                       CREATE USER MAPPING              DROP VIEW                        VACUUM
  CLOSE                            CREATE VIEW                      END                              VALUES
  CLUSTER                          DEALLOCATE                       EXECUTE                          WITH
  COMMENT                          DECLARE                          EXPLAIN