Home  >  Article  >  Database  >  postgres

postgres

WBOY
WBOYOriginal
2016-06-07 15:54:241116browse

postgres 连接数据库, 默认的用户和数据库是postgrespsql -U user -d dbname切换数据库,相当于mysql的use dbname\c dbname列举数据库,相当于mysql的show databases\l列举表,相当于mysql的show tables\dt查看表结构,相当于desc tblname,show columns from

postgres

连接数据库, 默认的用户和数据库是postgres
psql -U user -d dbname

切换数据库,相当于mysql的use dbname
\c dbname
列举数据库,相当于mysql的show databases
\l
列举表,相当于mysql的show tables
\dt
查看表结构,相当于desc tblname,show columns from tbname
\d tblname

\di 查看索引 

创建数据库: 
create database [数据库名]; 
删除数据库: 
drop database [数据库名];  
*重命名一个表: 
alter table [表名A] rename to [表名B]; 
*删除一个表: 
drop table [表名]; 
ps aux | grep postgres
psql postgres
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn