postgreSql使用入门
1.基本操作
#进入postgreSql su postgres psql #退出 \q #查看数据库 \l #选择数据库 \c databaseName #查看表 \d #查看表字段 \d tableName
2.springboot+mybatis+postgresql集成
配置: spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.url=jdbc:postgresql://host:port/dbname?characterEncoding=utf8&useSSL=false spring.datasource.username=postgres spring.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;
相关推荐
WanKaShing 2020-11-12
zhbvictor 2020-10-29
kls00 2020-10-15
89921334 2020-07-29
83911930 2020-07-28
89407707 2020-06-27
89921334 2020-06-26
89244553 2020-06-21
84593973 2020-06-21
83911930 2020-06-16
yaoding 2020-06-14
89244553 2020-06-11
89407707 2020-06-11
89921334 2020-06-10
89407707 2020-06-10
goodriver 2020-06-09
kevinli 2020-06-06
84593973 2020-06-05