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 postgres
psql (9.4.1) Type "help" for help.
postgres=#


Create DATABASE User xxx


CREATE USER xxx WITH PASSWORD ‘xxxxxx‘;


Create a database yyy and specify the owner as xxx


CREATE DATABASE yyy OWNER xxx;


Assign all operation permissions to the database yyy to user xxx, otherwise xxx can only log in to the console without any database operation permissions


GRANT ALL PRIVILEGES ON DATABASE yyy to xxx;


Delete Database yyy


DROP DATABASE yyy;


Delete User xxx


DROP USER XXX;


Exit Psql Console


\q


Common other commands


\ h: View the explanation of SQL commands, such as \ h select.
\ ?: View the list of psql commands.
\ l: List all databases.
\ c [database_name]: Connect to another database.
\ d: List all tables in the current database.
\ d [table_name]: List the structure of a table.
\ du: List all users.
\ e: Open a text editor.
\ conninfo: List information about the current database and connection.
\ password uesrname: Modify the database user password. 


Note: Basic database operations must be uppercase, such as Create,select.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.



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.