Показать сообщение отдельно
  #1  
Старый 11.03.2012, 11:38
Marley Marley вне форума
Senior Member
 
Регистрация: 19.09.2009
Сообщений: 7,211
По умолчанию Команды psql

PSQL

# su - postgres
$ createdb mydatabase
$ psql mydatabase

Код:
psql (9.1.3)
Type "help" for help.

mydatabase=#
mydatabase-# \h

Код:
Available help:
  ABORT                            DECLARE
  ALTER AGGREGATE                  DELETE
  ALTER COLLATION                  DISCARD
  ALTER CONVERSION                 DO
  ALTER DATABASE                   DROP AGGREGATE
  ALTER DEFAULT PRIVILEGES         DROP CAST
  ALTER DOMAIN                     DROP COLLATION
  ALTER EXTENSION                  DROP CONVERSION
  ALTER FOREIGN DATA WRAPPER       DROP DATABASE
  ALTER FOREIGN TABLE              DROP DOMAIN
  ALTER FUNCTION                   DROP EXTENSION
  ALTER GROUP                      DROP FOREIGN DATA WRAPPER
  ALTER INDEX                      DROP FOREIGN TABLE
  ALTER LANGUAGE                   DROP FUNCTION
  ALTER LARGE OBJECT               DROP GROUP
  ALTER OPERATOR                   DROP INDEX
  ALTER OPERATOR CLASS             DROP LANGUAGE
  ALTER OPERATOR FAMILY            DROP OPERATOR
  ALTER ROLE                       DROP OPERATOR CLASS
  ALTER SCHEMA                     DROP OPERATOR FAMILY
  ALTER SEQUENCE                   DROP OWNED
  ALTER SERVER                     DROP ROLE

mydatabase-# \h create database

Код:
Command:     CREATE DATABASE
Description: create a new database
Syntax:
CREATE DATABASE name
    [ [ WITH ] [ OWNER [=] user_name ]
           [ TEMPLATE [=] template ]
           [ ENCODING [=] encoding ]
           [ LC_COLLATE [=] lc_collate ]
           [ LC_CTYPE [=] lc_ctype ]
           [ TABLESPACE [=] tablespace ]
           [ CONNECTION LIMIT [=] connlimit ] ]


mydatabase-# \?

Код:
General
  \copyright             show PostgreSQL usage and distribution terms
  \g [FILE] or ;         execute query (and send results to file or |pipe)
  \h [NAME]              help on syntax of SQL commands, * for all commands
  \q                     quit psql

Query Buffer
  \e [FILE] [LINE]       edit the query buffer (or file) with external editor
  \ef [FUNCNAME [LINE]]  edit function definition with external editor
  \p                     show the contents of the query buffer
  \r                     reset (clear) the query buffer
  \s [FILE]              display history or save it to file
  \w FILE                write query buffer to file

Input/Output
  \copy ...              perform SQL COPY with data stream to the client host
  \echo [STRING]         write string to standard output
  \i FILE                execute commands from file
  \o [FILE]              send all query results to file or |pipe
  \qecho [STRING]        write string to query output stream (see \o)

Informational
  (options: S = show system objects, + = additional detail)
mydatabase-#
mydatabase-# \?
General
  \copyright             show PostgreSQL usage and distribution terms
  \g [FILE] or ;         execute query (and send results to file or |pipe)
  \h [NAME]              help on syntax of SQL commands, * for all commands
  \q                     quit psql

Query Buffer
  \e [FILE] [LINE]       edit the query buffer (or file) with external editor
  \ef [FUNCNAME [LINE]]  edit function definition with external editor
  \p                     show the contents of the query buffer
  \r                     reset (clear) the query buffer
  \s [FILE]              display history or save it to file
  \w FILE                write query buffer to file

Input/Output
  \copy ...              perform SQL COPY with data stream to the client host
  \echo [STRING]         write string to standard output
  \i FILE                execute commands from file
  \o [FILE]              send all query results to file or |pipe
  \qecho [STRING]        write string to query output stream (see \o)

// Покажет представления и таблицы
mydatabase-# \d

// Покажет структуру таблицы, PK и FK
mydatabase-# \d table_name


// Покажет представления
mydatabase-# \dv


// Показать таблицы
mydatabase-# \dt



mydatabase-# \conninfo
You are connected to database "mydatabase" as user "postgres" via socket in "/tmp" at port "5432".


\pset format html
\pset format aligned

\pset border 0

// Отображать null как null
\pset null null

// Указать заголовок к таблице.
\pset title employee
__________________
Чат форума (требуется аккаунт на github или twitter)

Последний раз редактировалось Marley; 12.03.2012 в 10:51.
Ответить с цитированием