包含postgresql退出的词条
PostgreSQL服务器启动及关闭方法
1. 启动数据库服务器(posgres用户):
网站建设哪家好,找成都创新互联公司!专注于网页设计、网站建设、微信开发、微信小程序、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了城中免费建站欢迎大家使用!
[postgres@localhost bin]$ postgres -D /opt/postgresql/data/ /opt/postgresql/log/pg_server.log 21
[1] 4508
当然如果设置了环境变量
PGDATA=/opt/postgresql/data
export PGDATA
后,可使用pg_ctl工具进行启动:
[postgres@localhost log]$ pg_ctl start -l /opt/postgresql/log/pg_server.log
pg_ctl: another server might be running; trying to start server anyway
pg_ctl: could not start server
Examine the log output.
[postgres@localhost log]$
因为之前已经启动,所以打印“another server might be running”。此时,查看日志,有如下信息:
[postgres@localhost log]$ cat pg_server.log
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 4491) running in data directory "/opt/postgresql/data"?
[postgres@localhost log]$
当然,最简的.启动方式是:
[postgres@localhost ~]$ pg_ctl start
server starting
[postgres@localhost ~]$ LOG: database system was shut down at 2011-07-09 13:58:00 CST
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
如果要在操作系统启动时就启动PG,可以在/etc/rc.d/rc.local 文件中加以下语句:
/opt/postgresql/bin/pg_ctl start -l /opt/postgresql/log/pg_server.log -D /opt/postgresql/data
2.关闭服务器
最简单方法:
[postgres@localhost ~]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
与Oracle相同,在关闭时也可采用不同的模式,简介如下:
SIGTERM
不再允许新的连接,但是允许所有活跃的会话正常完成他们的工作,只有在所有会话都结束任务后才关闭。这是智能关闭。
SIGINT
不再允许新的连接,向所有活跃服务器发送 SIGTERM(让它们立刻退出),然后等待所有子进程退出并关闭数据库。这是快速关闭。
SIGQUIT
令 postgres 向所有子进程发送 SIGQUIT 并且立即退出(所有子进程也会立即退出),而不会妥善地关闭数据库系统。这是立即关闭。这样做会导致下次启动时的恢复(通过重放 WAL 日志)。我们推荐只在紧急的时候使用这个方法。
SIGKILL
此选项尽量不要使用,这样会阻止服务器清理共享内存和信号灯资源,那样的话你只能在启动服务器之前自己手工做这件事。另外,SIGKILL 直接把 postgres 杀掉,而不会等它把信号中继给它的子进程,因此我们还需要手工杀掉每个独立子进程。
使用方法举例:
[postgres@localhost ~]$ pg_ctl stop -o SIGTERM
LOG: received smart shutdown request
LOG: autovacuum launcher shutting down
waiting for server to shut down....LOG: shutting down
LOG: database system is shut down
done
server stopped
[postgres@localhost ~]$
最快速关闭方法:kill postgres 进程
[postgres@localhost ~]$ kill -INT `head -1 /opt/postgresql/data/postmaster.pid`
[postgres@localhost ~]$ LOG: received fast shutdown request
LOG: aborting any active transactions
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down
附:postgre启动后的进程,如下:
[postgres@localhost ~]$ ps -ef|grep post
root 4609 4543 0 13:57 pts/2 00:00:00 su - postgres
postgres 4610 4609 0 13:57 pts/2 00:00:00 -bash
postgres 4724 1 0 14:08 pts/2 00:00:00 /opt/postgresql/bin/postgres
postgres 4726 4724 0 14:08 ? 00:00:00 postgres: writer process
postgres 4727 4724 0 14:08 ? 00:00:00 postgres: wal writer process
postgres 4728 4724 0 14:08 ? 00:00:00 postgres: autovacuum launcher process
postgres 4729 4724 0 14:08 ? 00:00:00 postgres: stats collector process
postgres 4752 4610 0 14:11 pts/2 00:00:00 ps -ef
postgres 4753 4610 0 14:11 pts/2 00:00:00 grep post
[postgres@localhost ~]$
postgresql psql 怎么退出
直接在命令行输入:quit或者是exist即可完成退出。
备注:其实最简单的方法就是关闭登录窗口,或者切换用户的形式完成退出当前用户的数据库操作。
如何退出postgresq数据库
启动数据库服务器(posgres用户)
[postgres@localhost bin]$ postgres D /opt/postgresql/data/ /opt/postgresql/log/pg_serverlog
[]
当然如果设置了环境变量
PGDATA=/opt/postgresql/data
export PGDATA
后可使用pg_ctl工具进行启动:
[postgres@localhost log]$ pg_ctl start l /opt/postgresql/log/pg_serverlog
pg_ctl: another server might be running; trying to start server anyway
pg_ctl: could not start server
Examine the log output
[postgres@localhost log]$
因为之前已经启动所以打印another server might be running此时查看日志有如下信息:
[postgres@localhost log]$ cat pg_serverlog
FATAL: lock file postmasterpid already exists
HINT: Is another postmaster (PID ) running in data directory /opt/postgresql/data?
[postgres@localhost log]$
当然最简的启动方式是
[postgres@localhost ~]$ pg_ctl start
server starting
[postgres@localhost ~]$ LOG: database system was shut down at :: CST
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
如果要在操作系统启动时就启动PG可以在/etc/rcd/rclocal 文件中加以下语句
/opt/postgresql/bin/pg_ctl start l /opt/postgresql/log/pg_serverlog D /opt/postgresql/data
关闭服务器
最简单方法
[postgres@localhost ~]$ pg_ctl stop
waiting for server to shut down done
server stopped
与Oracle相同在关闭时也可采用不同的模式简介如下
SIGTERM
不再允许新的连接但是允许所有活跃的会话正常完成他们的工作只有在所有会话都结束任务后才关闭这是智能关闭
SIGINT
不再允许新的连接向所有活跃服务器发送 SIGTERM(让它们立刻退出)然后等待所有子进程退出并关闭数据库这是快速关闭
SIGQUIT
令 postgres 向所有子进程发送 SIGQUIT 并且立即退出(所有子进程也会立即退出)而不会妥善地关闭数据库系统这是立即关闭这样做会导致下次启动时的恢复(通过重放 WAL 日志)我们推荐只在紧急的时候使用这个方法
SIGKILL
此选项尽量不要使用这样会阻止服务器清理共享内存和信号灯资源那样的话你只能在启动服务器之前自己手工做这件事另外SIGKILL 直接把 postgres 杀掉而不会等它把信号中继给它的子进程因此我们还需要手工杀掉每个独立子进程
使用方法举例
[postgres@localhost ~]$ pg_ctl stop o SIGTERM
LOG: received smart shutdown request
LOG: autovacuum launcher shutting down
waiting for server to shut downLOG: shutting down
LOG: database system is shut down
done
server stopped
[postgres@localhost ~]$
最快速关闭方法kill postgres 进程
[postgres@localhost ~]$ kill INT `head /opt/postgresql/data/postmasterpid`
[postgres@localhost ~]$ LOG: received fast shutdown request
LOG: aborting any active transactions
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down
附postgre启动后的进程如下:
[postgres@localhost ~]$ ps ef|grep post
root : pts/ :: su postgres
postgres : pts/ :: bash
postgres : pts/ :: /opt/postgresql/bin/postgres
postgres : ? :: postgres: writer process
postgres : ? :: postgres: wal writer process
postgres : ? :: postgres: autovacuum launcher process
postgres : ? :: postgres: stats collector process
postgres : pts/ :: ps ef
postgres : pts/ :: grep post
[postgres@localhost ~]$
【PostgreSQL】在 Linux 下操作 PostgreSQL 的指令
切换到 postgres 用户: sudo su - postgres
打开 PostgreSQL 控制台: psql ;退出控制台: quit
管理指令:
其他指令:
PostgreSQL Partition
create_range_partitions
select create_range_partitions('trip_agg_data'::regclass,'time_key',0::bigint,1::bigint,0,false) ;
trip_agg_data --主表OID
time_key --分区列名,必须有not null约束
0::bigint: --起始值 bigint取决于time_key 类型
1::bigint --间隔值 必须大于0
0 --分区个数
false --不立即迁移数据
add_range_partition
select add_range_partition('trip_agg_data'::REGCLASS,0,2019010100,'trip_agg_data_lt_20190101');
2019010100 不能超过time_key类型的最大值
partition_table_concurrently
select partition_table_concurrently ('trip_agg_data_tim'::regclass,10000, 1.0);
迁移数据到子表
10000 --一个事务批量迁移多少记录
1.0 --获得行锁失败时,休眠多久再次获取,重试60次退出任务
pathman_concurrent_part_tasks
select * from pathman_concurrent_part_tasks;
查看数据迁移进度
disable_pathman_for
select disable_pathman_for('trip_agg_data_tim'::regclass);
禁用分区
drop_range_partition
SELECT drop_range_partition(partition, false) /* move data to parent */
FROM pathman_partition_list WHERE parent = 'trip_agg_data'::regclass
and partition = 'trip_agg_data_greater_20200101'::regclass
删除某个分区表
pathman_partition_list
select * from pathman_partition_list;
查看所有分区表信息
set_enable_parent
select set_enable_parent('trip_agg_data'::regclass,false);
禁用主表
split_range_partition
分裂范围分区
merge_range_partitions
合并范围分区
append_range_partition
向后添加范围分区
prepend_range_partition
向前添加范围分区
drop_range_partition
drop_range_partition(partition TEXT, -- 分区名称
delete_data BOOLEAN DEFAULT TRUE) -- 是否删除分区数据,如果false,表示分区数据迁移到主表
drop_partitions
drop_partitions(parent REGCLASS,
delete_data BOOLEAN DEFAULT FALSE)
attach_range_partition
attach_range_partition(relation REGCLASS, -- 主表OID
partition REGCLASS, -- 分区表OID
start_value ANYELEMENT, -- 起始值
end_value ANYELEMENT) -- 结束值
detach_range_partition
detach_range_partition(partition REGCLASS) -- 指定分区名,转换为普通表
-- 1, create table trip_agg_data_2019
create table trip_agg_data_2019 as select * from trip_agg_data where 1=0;
alter table trip_agg_data_2019 alter column time_key set not null;
-- 2, create_range_partition
select create_range_partitions('trip_agg_data_2019'::regclass,'time_key',0::bigint,1::bigint,0,false) ;
-- 3, detach_range_partition for trip_agg_data'
select detach_range_partition('trip_agg_data_20190101');
select detach_range_partition('trip_agg_data_20190201');
select detach_range_partition('trip_agg_data_20190301');
select detach_range_partition('trip_agg_data_20190401');
select detach_range_partition('trip_agg_data_20190501');
select detach_range_partition('trip_agg_data_20190601');
select detach_range_partition('trip_agg_data_20190701');
select detach_range_partition('trip_agg_data_20190801');
select detach_range_partition('trip_agg_data_20190901');
select detach_range_partition('trip_agg_data_20191001');
select detach_range_partition('trip_agg_data_20191101');
select detach_range_partition('trip_agg_data_20191201');
-- 4, add_range_partition for trip_agg_data'
select add_range_partition('trip_agg_data'::REGCLASS,2019010100,2020010100,'trip_agg_data_20190101_20200101');
-- 5, attach_range_partition for trip_agg_data_2019
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20190101',2019010100,2019020100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20190201',2019020100,2019030100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20190301',2019030100,2019040100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20190401',2019040100,2019050100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20190501',2019050100,2019060100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20190601',2019060100,2019070100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20190701',2019070100,2019080100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20190801',2019080100,2019090100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20190901',2019090100,2019100100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20191001',2019100100,2019110100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20191101',2019110100,2019120100);
select attach_range_partition('trip_agg_data_2019'::REGCLASS,'trip_agg_data_20191201',2019120100,2020010100);
-- 6, disable parent for trip_agg_data_2019
select set_enable_parent('trip_agg_data_2019'::regclass,false);
alter table trip_agg_data alter column time_key set not null;
select create_range_partitions('trip_agg_data'::regclass,'time_key',0::bigint,1::bigint,0,false) ;
select add_range_partition('trip_agg_data'::REGCLASS,0,2019010100,'trip_agg_data_lt_20190101');
select add_range_partition('trip_agg_data'::REGCLASS,2019010100,2019020100,'trip_agg_data_20190101');
select add_range_partition('trip_agg_data'::REGCLASS,2019020100,2019030100,'trip_agg_data_20190201');
select add_range_partition('trip_agg_data'::REGCLASS,2019030100,2019040100,'trip_agg_data_20190301');
select add_range_partition('trip_agg_data'::REGCLASS,2019040100,2019050100,'trip_agg_data_20190401');
select add_range_partition('trip_agg_data'::REGCLASS,2019050100,2019060100,'trip_agg_data_20190501');
select add_range_partition('trip_agg_data'::REGCLASS,2019060100,2019070100,'trip_agg_data_20190601');
select add_range_partition('trip_agg_data'::REGCLASS,2019070100,2019080100,'trip_agg_data_20190701');
select add_range_partition('trip_agg_data'::REGCLASS,2019080100,2019090100,'trip_agg_data_20190801');
select add_range_partition('trip_agg_data'::REGCLASS,2019090100,2019100100,'trip_agg_data_20190901');
select add_range_partition('trip_agg_data'::REGCLASS,2019100100,2019110100,'trip_agg_data_20191001');
select add_range_partition('trip_agg_data'::REGCLASS,2019110100,2019120100,'trip_agg_data_20191101');
select add_range_partition('trip_agg_data'::REGCLASS,2019120100,2020010100,'trip_agg_data_20191201');
select add_range_partition('trip_agg_data'::REGCLASS,2020010100,2020020100,'trip_agg_data_20200101');
select add_range_partition('trip_agg_data'::REGCLASS,2020020100,2020030100,'trip_agg_data_20200201');
select add_range_partition('trip_agg_data'::REGCLASS,2020030100,2020040100,'trip_agg_data_20200301');
select add_range_partition('trip_agg_data'::REGCLASS,2020040100,2020050100,'trip_agg_data_20200401');
select add_range_partition('trip_agg_data'::REGCLASS,2020050100,2020060100,'trip_agg_data_20200501');
select add_range_partition('trip_agg_data'::REGCLASS,2020060100,2020070100,'trip_agg_data_20200601');
select add_range_partition('trip_agg_data'::REGCLASS,2020070100,2020080100,'trip_agg_data_20200701');
select add_range_partition('trip_agg_data'::REGCLASS,2020080100,2020090100,'trip_agg_data_20200801');
select add_range_partition('trip_agg_data'::REGCLASS,2020090100,2020100100,'trip_agg_data_20200901');
select add_range_partition('trip_agg_data'::REGCLASS,2020100100,2020110100,'trip_agg_data_20201001');
select add_range_partition('trip_agg_data'::REGCLASS,2020110100,2020120100,'trip_agg_data_20201101');
select add_range_partition('trip_agg_data'::REGCLASS,2020120100,2021010100,'trip_agg_data_20201201');
select add_range_partition('trip_agg_data'::REGCLASS,2021010100,2021020100,'trip_agg_data_20210101');
select add_range_partition('trip_agg_data'::REGCLASS,2021020100,2021030100,'trip_agg_data_20210201');
select add_range_partition('trip_agg_data'::REGCLASS,2021030100,2021040100,'trip_agg_data_20210301');
select add_range_partition('trip_agg_data'::REGCLASS,2021040100,2021050100,'trip_agg_data_20210401');
select add_range_partition('trip_agg_data'::REGCLASS,2021050100,2021060100,'trip_agg_data_20210501');
select add_range_partition('trip_agg_data'::REGCLASS,2021060100,2021070100,'trip_agg_data_20210601');
select add_range_partition('trip_agg_data'::REGCLASS,2021070100,2021080100,'trip_agg_data_20210701');
select add_range_partition('trip_agg_data'::REGCLASS,2021080100,2021090100,'trip_agg_data_20210801');
select add_range_partition('trip_agg_data'::REGCLASS,2021090100,2021100100,'trip_agg_data_20210901');
select add_range_partition('trip_agg_data'::REGCLASS,2021100100,2021110100,'trip_agg_data_20211001');
select add_range_partition('trip_agg_data'::REGCLASS,2021110100,2021120100,'trip_agg_data_20211101');
select add_range_partition('trip_agg_data'::REGCLASS,2021120100,2022010100,'trip_agg_data_20211201');
select add_range_partition('trip_agg_data'::REGCLASS,2022010100,2022020100,'trip_agg_data_20220101');
select add_range_partition('trip_agg_data'::REGCLASS,2022020100,2022030100,'trip_agg_data_20220201');
select add_range_partition('trip_agg_data'::REGCLASS,2022030100,2022040100,'trip_agg_data_20220301');
select add_range_partition('trip_agg_data'::REGCLASS,2022040100,2022050100,'trip_agg_data_20220401');
select add_range_partition('trip_agg_data'::REGCLASS,2022050100,2022060100,'trip_agg_data_20220501');
select add_range_partition('trip_agg_data'::REGCLASS,2022060100,2022070100,'trip_agg_data_20220601');
select add_range_partition('trip_agg_data'::REGCLASS,2022070100,2022080100,'trip_agg_data_20220701');
select add_range_partition('trip_agg_data'::REGCLASS,2022080100,2022090100,'trip_agg_data_20220801');
select add_range_partition('trip_agg_data'::REGCLASS,2022090100,2022100100,'trip_agg_data_20220901');
select add_range_partition('trip_agg_data'::REGCLASS,2022100100,2022110100,'trip_agg_data_20221001');
select add_range_partition('trip_agg_data'::REGCLASS,2022110100,2022120100,'trip_agg_data_20221101');
select add_range_partition('trip_agg_data'::REGCLASS,2022120100,2023010100,'trip_agg_data_20221201');
select add_range_partition('trip_agg_data'::REGCLASS,2023010100,2023020100,'trip_agg_data_20230101');
select add_range_partition('trip_agg_data'::REGCLASS,2023020100,2023030100,'trip_agg_data_20230201');
select add_range_partition('trip_agg_data'::REGCLASS,2023030100,2023040100,'trip_agg_data_20230301');
select add_range_partition('trip_agg_data'::REGCLASS,2023040100,2023050100,'trip_agg_data_20230401');
select add_range_partition('trip_agg_data'::REGCLASS,2023050100,2023060100,'trip_agg_data_20230501');
select add_range_partition('trip_agg_data'::REGCLASS,2023060100,2023070100,'trip_agg_data_20230601');
select add_range_partition('trip_agg_data'::REGCLASS,2023070100,2023080100,'trip_agg_data_20230701');
select add_range_partition('trip_agg_data'::REGCLASS,2023080100,2023090100,'trip_agg_data_20230801');
select add_range_partition('trip_agg_data'::REGCLASS,2023090100,2023100100,'trip_agg_data_20230901');
select add_range_partition('trip_agg_data'::REGCLASS,2023100100,2023110100,'trip_agg_data_20231001');
select add_range_partition('trip_agg_data'::REGCLASS,2023110100,2023120100,'trip_agg_data_20231101');
select add_range_partition('trip_agg_data'::REGCLASS,2023120100,2024010100,'trip_agg_data_20231201');
select add_range_partition('trip_agg_data'::REGCLASS,2024010100,2024020100,'trip_agg_data_20240101');
select add_range_partition('trip_agg_data'::REGCLASS,2024020100,2024030100,'trip_agg_data_20240201');
select add_range_partition('trip_agg_data'::REGCLASS,2024030100,2024040100,'trip_agg_data_20240301');
select add_range_partition('trip_agg_data'::REGCLASS,2024040100,2024050100,'trip_agg_data_20240401');
select add_range_partition('trip_agg_data'::REGCLASS,2024050100,2024060100,'trip_agg_data_20240501');
select add_range_partition('trip_agg_data'::REGCLASS,2024060100,2024070100,'trip_agg_data_20240601');
select add_range_partition('trip_agg_data'::REGCLASS,2024070100,2024080100,'trip_agg_data_20240701');
select add_range_partition('trip_agg_data'::REGCLASS,2024080100,2024090100,'trip_agg_data_20240801');
select add_range_partition('trip_agg_data'::REGCLASS,2024090100,2024100100,'trip_agg_data_20240901');
select add_range_partition('trip_agg_data'::REGCLASS,2024100100,2024110100,'trip_agg_data_20241001');
select add_range_partition('trip_agg_data'::REGCLASS,2024110100,2024120100,'trip_agg_data_20241101');
select add_range_partition('trip_agg_data'::REGCLASS,2024120100,2025010100,'trip_agg_data_20241201');
select add_range_partition('trip_agg_data'::REGCLASS,2025010100,2025020100,'trip_agg_data_20250101');
select add_range_partition('trip_agg_data'::REGCLASS,2025020100,2025030100,'trip_agg_data_20250201');
select add_range_partition('trip_agg_data'::REGCLASS,2025030100,2025040100,'trip_agg_data_20250301');
select add_range_partition('trip_agg_data'::REGCLASS,2025040100,2025050100,'trip_agg_data_20250401');
select add_range_partition('trip_agg_data'::REGCLASS,2025050100,2025060100,'trip_agg_data_20250501');
select add_range_partition('trip_agg_data'::REGCLASS,2025060100,2025070100,'trip_agg_data_20250601');
select add_range_partition('trip_agg_data'::REGCLASS,2025070100,2025080100,'trip_agg_data_20250701');
select add_range_partition('trip_agg_data'::REGCLASS,2025080100,2025090100,'trip_agg_data_20250801');
select add_range_partition('trip_agg_data'::REGCLASS,2025090100,2025100100,'trip_agg_data_20250901');
select add_range_partition('trip_agg_data'::REGCLASS,2025100100,2025110100,'trip_agg_data_20251001');
select add_range_partition('trip_agg_data'::REGCLASS,2025110100,2025120100,'trip_agg_data_20251101');
select add_range_partition('trip_agg_data'::REGCLASS,2025120100,2026010100,'trip_agg_data_20251201');
select add_range_partition('trip_agg_data'::REGCLASS,2026010100,2026020100,'trip_agg_data_20260101');
select add_range_partition('trip_agg_data'::REGCLASS,2026020100,2026030100,'trip_agg_data_20260201');
select add_range_partition('trip_agg_data'::REGCLASS,2026030100,2026040100,'trip_agg_data_20260301');
select add_range_partition('trip_agg_data'::REGCLASS,2026040100,2026050100,'trip_agg_data_20260401');
select add_range_partition('trip_agg_data'::REGCLASS,2026050100,2026060100,'trip_agg_data_20260501');
select add_range_partition('trip_agg_data'::REGCLASS,2026060100,2026070100,'trip_agg_data_20260601');
select add_range_partition('trip_agg_data'::REGCLASS,2026070100,2026080100,'trip_agg_data_20260701');
select add_range_partition('trip_agg_data'::REGCLASS,2026080100,2026090100,'trip_agg_data_20260801');
select add_range_partition('trip_agg_data'::REGCLASS,2026090100,2026100100,'trip_agg_data_20260901');
select add_range_partition('trip_agg_data'::REGCLASS,2026100100,2026110100,'trip_agg_data_20261001');
select add_range_partition('trip_agg_data'::REGCLASS,2026110100,2026120100,'trip_agg_data_20261101');
select add_range_partition('trip_agg_data'::REGCLASS,2026120100,2027010100,'trip_agg_data_20261201');
select add_range_partition('trip_agg_data'::REGCLASS,2027010100,2027020100,'trip_agg_data_20270101');
select add_range_partition('trip_agg_data'::REGCLASS,2027020100,2027030100,'trip_agg_data_20270201');
select add_range_partition('trip_agg_data'::REGCLASS,2027030100,2027040100,'trip_agg_data_20270301');
select add_range_partition('trip_agg_data'::REGCLASS,2027040100,2027050100,'trip_agg_data_20270401');
select add_range_partition('trip_agg_data'::REGCLASS,2027050100,2027060100,'trip_agg_data_20270501');
select add_range_partition('trip_agg_data'::REGCLASS,2027060100,2027070100,'trip_agg_data_20270601');
select add_range_partition('trip_agg_data'::REGCLASS,2027070100,2027080100,'trip_agg_data_20270701');
select add_range_partition('trip_agg_data'::REGCLASS,2027080100,2027090100,'trip_agg_data_20270801');
select add_range_partition('trip_agg_data'::REGCLASS,2027090100,2027100100,'trip_agg_data_20270901');
select add_range_partition('trip_agg_data'::REGCLASS,2027100100,2027110100,'trip_agg_data_20271001');
select add_range_partition('trip_agg_data'::REGCLASS,2027110100,2027120100,'trip_agg_data_20271101');
select add_range_partition('trip_agg_data'::REGCLASS,2027120100,2028010100,'trip_agg_data_20271201');
select add_range_partition('trip_agg_data'::REGCLASS,2028010100,2028020100,'trip_agg_data_20280101');
select add_range_partition('trip_agg_data'::REGCLASS,2028020100,2028030100,'trip_agg_data_20280201');
select add_range_partition('trip_agg_data'::REGCLASS,2028030100,2028040100,'trip_agg_data_20280301');
select add_range_partition('trip_agg_data'::REGCLASS,2028040100,2028050100,'trip_agg_data_20280401');
select add_range_partition('trip_agg_data'::REGCLASS,2028050100,2028060100,'trip_agg_data_20280501');
select add_range_partition('trip_agg_data'::REGCLASS,2028060100,2028070100,'trip_agg_data_20280601');
select add_range_partition('trip_agg_data'::REGCLASS,2028070100,2028080100,'trip_agg_data_20280701');
select add_range_partition('trip_agg_data'::REGCLASS,2028080100,2028090100,'trip_agg_data_20280801');
select add_range_partition('trip_agg_data'::REGCLASS,2028090100,2028100100,'trip_agg_data_20280901');
select add_range_partition('trip_agg_data'::REGCLASS,2028100100,2028110100,'trip_agg_data_20281001');
select add_range_partition('trip_agg_data'::REGCLASS,2028110100,2028120100,'trip_agg_data_20281101');
select add_range_partition('trip_agg_data'::REGCLASS,2028120100,2029010100,'trip_agg_data_20281201');
select add_range_partition('trip_agg_data'::REGCLASS,2029010100,2029020100,'trip_agg_data_20290101');
select add_range_partition('trip_agg_data'::REGCLASS,2029020100,2029030100,'trip_agg_data_20290201');
select add_range_partition('trip_agg_data'::REGCLASS,2029030100,2029040100,'trip_agg_data_20290301');
select add_range_partition('trip_agg_data'::REGCLASS,2029040100,2029050100,'trip_agg_data_20290401');
select add_range_partition('trip_agg_data'::REGCLASS,2029050100,2029060100,'trip_agg_data_20290501');
select add_range_partition('trip_agg_data'::REGCLASS,2029060100,2029070100,'trip_agg_data_20290601');
select add_range_partition('trip_agg_data'::REGCLASS,2029070100,2029080100,'trip_agg_data_20290701');
select add_range_partition('trip_agg_data'::REGCLASS,2029080100,2029090100,'trip_agg_data_20290801');
select add_range_partition('trip_agg_data'::REGCLASS,2029090100,2029100100,'trip_agg_data_20290901');
select add_range_partition('trip_agg_data'::REGCLASS,2029100100,2029110100,'trip_agg_data_20291001');
select add_range_partition('trip_agg_data'::REGCLASS,2029110100,2029120100,'trip_agg_data_20291101');
select add_range_partition('trip_agg_data'::REGCLASS,2029120100,2030010100,'trip_agg_data_20291201');
select add_range_partition('trip_agg_data'::REGCLASS,2030010100,2147483647,'trip_agg_data_gt_20300101');
select partition_table_concurrently ('trip_agg_data'::regclass,10000, 1.0);
select set_enable_parent('trip_agg_data'::regclass,false);
如何重置postgresql用户密码
1.
修改PostgreSQL数据库默认用户postgres的密码
PostgreSQL数据库创建一个postgres用户作为数据库的管理员,密码随机,所以需要修改密码,方式如下:
步骤一:登录PostgreSQL
1
sudo
-u
postgres
psql
步骤二:修改登录PostgreSQL密码
1
ALTER
USER
postgres
WITH
PASSWORD
'postgres';
注:
密码postgres要用引号引起来
命令最后有分号
步骤三:退出PostgreSQL客户端
\q
分享标题:包含postgresql退出的词条
分享网址:http://azwzsj.com/article/dsdgdsd.html