PostgreSQL Database psql Console action command

Source: Internet
Author: User
Tags psql



Log in to the PostgreSQL database console


Psql database name


Login successful Display


[zpf@kevin ~]$ psql postgrespsql (9.4.1)Type"help"for help.postgres=#


Create DATABASE User xxx


CREATE USER xxx WITH PASSWORD ‘xxxxxx‘;


Create a database yyy and specify all of them as xxx


CREATE DATABASE yyy OWNER xxx;


To the database yyy all operation permissions assigned to the user xxx, otherwise xxx can only login to the console, no matter what the database operation rights


GRANT ALL PRIVILEGES ON DATABASE yyy to xxx;


Delete Database yyy


DROP DATABASE yyy;


Delete User xxx


DROP USER XXX;


Exit Psql Console


\q


Use other commands frequently


\h: View the explanation of the SQL command, such as \h select.
\?
: View the list of psql commands.
\l: List all databases.
\c [database_name]: Connect to other databases.
\d: List all tables in the current database.
\d [table_name]: Lists the structure of a table.

\du: List all users.
\e: Open the text editor.

\conninfo: Lists information about the current database and connections.
\password uesrname : Change the database user password. 

Note: The primary database operation must be uppercase. such as create. Select and so on.



PostgreSQL Database psql Console action command


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.