postgresql日常操作命令
創(chuàng)建數(shù)據(jù)庫:?
create database [數(shù)據(jù)庫名];?
刪除數(shù)據(jù)庫:?
drop database [數(shù)據(jù)庫名]; ?
列舉庫,相當于mysql的show databases
test=> \l
切換庫,相當于mysql的use databases
test-> \c [數(shù)據(jù)庫名]
創(chuàng)建表
test=> CREATE TABLE [表名] (
? ? product_no integer,
? ? name text,
? ? price numeric
);
列舉表,相當于mysql的show tables
test=> \dt
插入數(shù)據(jù)
test=> INSERT INTO [表名] VALUES ([值1], '[值2]', [值3]);
查看表結(jié)構(gòu),相當于mysql的desc tblname,show columns from tbname
test=> \d [表名]
?
?\di 查看索引?
?
重命名表名
test=> alter table [表名] rename to [新表名];
刪除數(shù)據(jù)庫:?
drop database [數(shù)據(jù)庫名];?
?
*刪除一個表:?
drop table [表名];
切換用戶
\c ?[用戶名]
查看當前連接的用戶名
select user;
or
select * from current_user;
查看所有用戶名
\du
帳號密碼修改
alter user [用戶名] with password '[新密碼]';
參考:
https://blog.csdn.net/u010856284/article/details/70142810
轉(zhuǎn)載于:https://blog.51cto.com/xiaoxiaozhou/2380191
與50位技術專家面對面20年技術見證,附贈技術全景圖總結(jié)
以上是生活随笔為你收集整理的postgresql日常操作命令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 总结了点React,咱也不敢说
- 下一篇: 思必驰携手博泰,共创智能汽车新声代