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