PostgreSQL command line

Source: Internet
Author: User
Tags psql

Original article link

PostgreSQL 8.1 Chinese Document

Connect to the database. The default user and database are ipvs.
Psql-u user-D dbname

\ C dbname: equivalent to MySQL's use dbname

\ L lists databases, which is equivalent to MySQL's show Databases

\ DT lists tables, equivalent to show tables

\ D tblname: view the table structure, which is equivalent to desc tblname, show columns from tbname

 

General
\ C [onnect] [database name |-User Name |-host |-port number |-]
Connect to the new database (currently "test ")
\ CD [Directory] change the current working directory
\ Copyright: displays the usage and release terms of PostgreSQL.
\ Encoding [character encoding name]
Display or set user-side character encoding
\ H [name] SQL command syntax description, use * to display all commands
\ Prompt [text] Name
Prompt the user to set internal variables
\ Password [username]
Securely change the password for a user
\ Q exit Psql
\ Set [name [number of values]
Set internal variables. If no parameter exists, all variables are listed.
\ Timing switch command timing switch (currently off)
\ Unset name clear (delete) Internal Variable
\! [Command] execute commands in shell or open a shell

Query the cache area
\ E [Archive] use an external editor to edit and query the cache (or archive)
\ G [file] sends the query cache to the server (and writes the result to the file or | Pipeline "pipe ")
\ P displays the content of the query cache.
\ R reset (clear) query Cache
\ W archive writes the query cache into the archive

Input/Output
\ Echo [String] writes the string to the standard output
\ I file command execution from File
\ O [file] writes all query results to the file or | Pipeline "pipe"
\ Qecho [String]
Write the string to the query output stream (refer to \ O)
Information
\ D [name]: Add annotation to the data table, index, sequence number, or view table
\ D {T | I | S | v | S} [model] (plus "+" for more information)
List data tables/indexes/sequence numbers/View tables/System Data Tables
\ Da [model] listing Aggregate functions
\ DB [model] list tablespaces (plus "+" for more information)
\ DC [model] listing character encoding and conversion
\ DC list type conversion
\ Dd [model] displays object annotations
\ Dd [model] listing common value ranges
\ DF [model] list functions (plus "+" for more information)
\ DF [model] lists text search configurations (plus "+" for more information)
\ DFB [model] lists text search dictionaries (plus "+" for more information)
\ DFT [model] lists text search styles
\ DFP [model] list text search analyzer (plus "+" for more information)
\ DG [model] list groups
\ DN [model] list architecture modes (plus "+" for more information)
\ Do [name] list Operators
\ DL: List large objects, same as \ lo_list
\ DP [model] Permission to list data tables, View tables, and sequence numbers
\ Dt [model] lists data types (plus "+" for more information)
\ Du [model] list roles
\ L list all databases (plus "+" for more information)
\ Z [model] Permission to list data tables, View tables, and sequence numbers (same as \ DP)

Format
\ A switch between non-alignment mode and alignment Mode
\ C [String]: Set the table title or cancel
\ F [String] displays or sets the column Separator of the Non-Alignment Mode
\ H switch the HTML output mode (currently disabled)
\ Pset name [number of values]
Set data table output options
(Name: = {format | border | expanded | fieldsep | footer | null |
Recordsep | tuples_only | title | tableattr | pager })
\ T only displays data columns (currently closed)
\ T [String] Set HTML table tag attributes
\ X switch to extended output mode (disabled currently)
Copy, large object)
\ Copy... Execute SQL copy, and the data stream points to the client host
\ Lo_export loboid File
\ Lo_import file [comment]
\ Lo_list
\ Lo_unlink loboid large object Operator

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.