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