Answer

问题及解答

PostgreSQL 中的基本操作

Posted by haifeng on 2014-10-13 17:59:16 last update 2014-12-01 11:28:57 | Edit | Answers (0)

与 MySQL 进行对比

mysql: SHOW TABLES
postgresql: \d
postgresql: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';

mysql: SHOW DATABASES
postgresql: \l
postgresql: SELECT datname FROM pg_database;

mysql: SHOW COLUMNS
postgresql: \d table
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name ='table';

mysql: DESCRIBE TABLE
postgresql: \d+ table
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name ='table';

 


更改表的结构使用 ALTER TABLE 语句

1. 增加一个名为 avatar 的属性 (avatar: 头像)

ALTER TABLE userinfo ADD COLUMN avatar varchar(255);

2. 删除刚才建的属性 avatar

ALTER TABLE userinfo DROP COLUMN avatar;


http://www.linuxscrew.com/2009/07/03/postgresql-show-tables-show-databases-show-columns/

http://blog.163.com/ruihuadesunny@126/blog/static/39026191200952231259710/