postgresql-user, library, mode, table

Source: Internet
Author: User
Tags postgresql psql ssl connection

Because do not understand PostgreSQL psql tool, after the database is installed directly with the Pgadmin or navicat to connect the operation, in the confirmation of the initialization of the library after the default some things have been nowhere to start, in the case of the PG general system has not been made confused, First of all, the database role can be both a user and the concept of a group, always struggling to query the current operation is which library which table, which mode of the state, even the table structure do not know how to see. Then still take the time to learn the basic elements of PG, mainly because of MySQL's generational relationship, the two have similar places, but in the management system is not the same. Finally, the first return to the server side, directly with Psql to operate first, to understand the psql defined meta-commands, easy to learn to learn.

Build new roles and libraries

Login ' 111111 ' ; CREATE ROLE

postgres=# Create Database Yun owner Chen;
CREATE DATABASE

Switch the role, after switching the prompt also from # into the superuser;

postgres=# \c- Chen; SSL connection (encryption: DHE"postgres" "Chen".

Postgres=>

Switch libraries

Postgres=> \c Yun;
)
" Yun " " Chen ".

Yun=>

New mode

Yun=> Create Schema Yun; CREATE SCHEMA

Here is a new table if the mode is not specified by default in which mode of the problem, different modes of different tables can be the same name, the \d command is also from the face of the schema names to get what table

Yun=>show Search_path;
Search_path
----------------
"$user", public
Yun=> set Search_path to Yun,"$user", public; SET
Yun=> show Search_path; Search_path ----------------------"$user", Public (1 rows)

When set, the new table is automatically returned to the Yun mode, and a new table is created.

yun=> CREATE TABLE website (Yun (int  primary Key,yun (> name varchar (255  Null, Yun (> URL varchar (255null, Yun (null) Yun- ;

The copy command requires Superuser to import data from a file that has been exported from MySQL in advance, but Psql provides another way to guide the data

' /var/lib/mysql/yun/src_data/allwebsite.dat ' ' , ';

Modify, add a new field

Yun=> ALTER TABLE website add column tm_update timestamp (0timenull  default now (); ALTER TABLE

postgresql-user, library, mode, table

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.