創建數據庫:
create database [數據庫名];
刪除數據庫:
drop database [數據庫名];
列舉庫,相當於mysql的show databases
test=> \l
切換庫,相當於mysql的use databases
test-> \c [數據庫名]
創建表
test=> CREATE TABLE [表名] (
product_no integer,
name text,
price numeric
);
列舉表,相當於mysql的show tables
test=> \dt
插入數據
test=> INSERT INTO [表名] VALUES ([值1], '[值2]', [值3]);
查看錶結構,相當於mysql的desc tblname,show columns from tbname
test=> \d [表名]
\di 查看索引
重命名錶名
test=> alter table [表名] rename to [新表名];
刪除數據庫:
drop database [數據庫名];
*刪除一個表:
drop table [表名];
切換用戶
\c [用戶名]
查看當前連接的用戶名
select user;
or
select * from current_user;
查看所有用戶名
\du
帳號密碼修改
alter user [用戶名] with password '[新密碼]';
參考:
https://blog.csdn.net/u010856284/article/details/70142810