PostgreSQL command line and database backup and recovery

Source: Internet
Author: User
Tags psql postgresql backup

Enter PostgreSQL

1 Enter the database default installation will create Postgres users, using Postgres user, Psql command directly into the database: Bash code $ su postgres//psql user $   Psql//default direct access to $ psql-u posrgres-d dbname//Use the Psql command to go in as database management   2 Display Database Bash code $ \l 3 Select Use a database bash code \c dbname 4 show datasheet Bash code $ \DT 5 Add password for postgres user bash code $ \password Postgre Modify the peer mode in vim/etc/postgresql/9.1/main/pg_hba.conf to MD5 command line common operations

1.createdb database name
Generate Database
2.DROPDB database name
Deleting a database

3.CREATE User Name
Create user
4.drop User Name
Delete User

5.SELECT usename from Pg_user;
View System User Information
\du

7.SELECT version ();
View version Information

8.psql Database name
Open the Psql Interactive tool

9.mydb=> \i Basics. SQL
The \i command reads the command from the specified file.

10.COPY weather from '/home/user/weather.txt ';
Bulk importing content from a text file into a wether table

11.SHOW Search_path;
Show Search Path

12. Create a user
CREATE user username with PASSWORD ' password '

13. Create a pattern
CREATE SCHEMA MySchema;

14. Delete Mode
DROP SCHEMA MySchema;

15. View the search mode
SHOW Search_path;

16. Set the search mode
SET Search_path to Myschema,public;

17. Create a table space
Create tablespace table space Name location ' file path ';

18. Display Default Tablespace
Show Default_tablespace;

19. Set the default table space
Set default_tablespace= table space name;

20. Specify User Login
Psql Mtps-u

21. Displays the current system time,
Now ()

PostgreSQL Backup and import 1 Backup

PostgreSQL command line and database backup and recovery

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.