Common commands for POSTGRESQL Getting Started

Source: Internet
Author: User

1. Command line logon Database
Psql-u username-d dbname-h hostip-p Port
2. List all databases
3. Switching the database
\c dbname
4. List all tables in the current database
5. View all fields of the specified table
\d  TableName

6. View the basic situation of the specified table
\d+  TableName

7. Exit operation
Q
8. Create a new table
CREATE TABLE Rel_cross_node (ID integer, cross_id integer);
9. Delete a table
drop table Rel_cross_node;
10. Add a Field
ALTER TABLE [table name] Add column [Field name] [type];
11. Changing fields
ALTER TABLE [table name] Rename column [old field name] to [new field name];
12. Delete a field
ALTER TABLE [table name] Drop column [field name];
13. Add a row of data to the table
insert into [table name] (field 1, Field 2) VALUES (value 1, value 2);
14. Delete a row of data in a table
15. Modify the data in the table
Update [table name] set [Target Field name]=[target value] where [the row feature]
16. Delete a table
drop table [table name];
17. Exit PostgreSQL
\q
18. Two results of the query do poor except
(select node_id from node where node_id=1 or node_id=2) except (select node_id from node where node_id=1); node_id---------       2 (1 row)

 

Common commands for POSTGRESQL Getting Started

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.