Postgresql(PG)表的操作:
PG表的支持数据类型:
数值数据类型
字符串数据类型
日期/时间数据类型
#创建库
postgres=# create database mydb;
CREATE DATABASE
postgres=# \c mydb
You are now connected to database "mydb" as user "postgres".
mydb=# \d
Did not find any relations.
#创建表
mydb=# create table test(id serial primary key,name varchar(255));
CREATE TABLE
#查看表结构:
mydb=# \d test
Table "public.test"
Column | Type | Collation | Nullable | Default
--------+------------------------+-----------+----------+----------------------------------
id | integer | | not null | nextval('test_id_seq'::regclass)
name | character varying(255) | | |
Indexes:
"test_pkey" PRIMARY KEY, btree (id)
mydb=#
##插入数据
mydb=# insert into test(name) values('zhangsan');
INSERT 0 1
mydb=# select * from test;
id | name
----+----------
1 | lisi
2 | wangwu
3 | zhangsan
(3 rows)
##更新数据
mydb=# update test set name='zhsan' where id=3;
UPDATE 1
mydb=# select * from test;
id | name
----+--------
1 | lisi
2 | wangwu
3 | zhsan
(3 rows)
##删除数据
mydb=# delete from test where name='lisi' and id=1;
DELETE 1
mydb=# select * from test;
id | name
----+--------
2 | wangwu
3 | zhsan
(2 rows)
mydb=#
在远程sqlserver上面查看刚刚创建的表数据
应该默认在public库下面: