PostgreSQL 常用语句

 

postgres=# create database mydb;
CREATE DATABASE


postgres=# alter database mydb;
ALTER DATABASE


postgres=# create table mydbtable(name varchar(80),year int);
CREATE TABLE


postgres=# create table mydbtable(name varchar(80),year int);
ERROR:  relation "mydbtable" already exists


postgres=# insert into mydbtable (name,year) values ('xiaoming',23);
INSERT 0 1


postgres=# table mydbtable;
   name   | year 
----------+------
 xiaoming |   23
(1 row)


postgres=# select * from mydbtable;
   name   | year 
----------+------
 xiaoming |   23
(1 row)



postgres=# select name from mydbtable;
   name   
----------
 xiaoming
(1 row)



postgres=# insert into mydbtable (name,year) values ('xiaohong',23);
INSERT 0 1
postgres=# select name from mydbtable;
   name   
----------
 xiaoming
 xiaohong
(2 rows)



postgres=# update mydbtable set name = 'xiaohei' where name='xiaohong';
UPDATE 1
postgres=# select name from mydbtable;
   name   
----------
 xiaoming
 xiaohei
(2 rows)
postgres=# 


postgres=# delete from mydbtable where name='xiaohei';
DELETE 1
postgres=# select name from mydbtable;
   name   
----------
 xiaoming
(1 row)


postgres=# delete from mydbtable;
DELETE 1
postgres=# select * from mydbtable;
 name | year 
------+------
(0 rows)
postgres=# 


postgres=# create database testdb;
CREATE DATABASE


postgres=# alter database testdb;
ALTER DATABASE

 

上一篇:Vue CLI 3.0脚手架如何在本地配置mock数据


下一篇:Git 内部原理 - (7)维护与数据恢复 (8) 环境变量 (9)总结