1.基本操作
#进入postgreSqlsu postgrespsql#退出\q#查看数据库\l#选择数据库\c databaseName#查看表\d#查看表字段\d tableName
2.springboot+mybatis+postgresql集成
配置:spring.datasource.driver-class-name=org.postgresql.Driverspring.datasource.url=jdbc:postgresql://host:port/dbname?characterEncoding=utf8&useSSL=falsespring.datasource.username=postgresspring.datasource.password=依赖:<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.5</version></dependency>表创建:CREATE TABLE user( A_ID SERIAL NOT NULL, B_ID integer, V_ID character varying(16), USER_ID bigint, CREATE_DATE date, CONSTRAINT user_pkey PRIMARY KEY (A_ID))SERIAL指自增数据库配置修改:在/var/lib/pgsql/11/data/postgresql.conf 新增listen_addresses = ‘*‘ 和 port = 5432在/var/lib/pgsql/11/data/pg_hba.conf 新增本机ip“host all all 本机ip/32 trust”数据库启动和停止:ps -ef | grep postgre/usr/pgsql-11/bin/pg_ctl -D /var/lib/pgsql/11/data/ start/usr/pgsql-11/bin/pg_ctl -D /var/lib/pgsql/11/data/ stop
3.修改字段类型
ALTER TABLE user ALTER COLUMN create_date TYPE TIMESTAMPTZ;
4.显示当前时区
SHOW TIMEZONE;
5.(数据类型)时间戳+时区
TIMESTAMPTZ
6.排序
排序 ORDER BY 升序 ASC 默认降序 DESC语法 SELECT column_name,column_name FROM table_name ORDER BY column_name DESC;