![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据库
mysql、postgresql
eryou_979
这个作者很懒,什么都没留下…
展开
-
Redis自定义序列化
Redis自定义序列化配置类/** * redis序列化配置 * @author dlz * @version 1.0.0 * @date 2021/6/1 19:49 */@Configurationpublic class RedisSerializerConfig { @Bean public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnecti原创 2021-06-01 20:35:36 · 267 阅读 · 0 评论 -
centos7-timescaledb插件安装(基于postgresql12)
最近用到timescaledb插件,特地看了一下官方文档,整理了一番,方便自己以后使用。环境是centos7官方地址一、准备# Download PGDG:sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm二、安装# Add timescaledb reposudo t原创 2021-06-16 20:59:03 · 441 阅读 · 0 评论 -
centos7-postgresql主从配置
本文postgresql主从配置基于postgresql12安装全过程一、准备两台服务器:192.168.116.10、192.168.116.11二、配置主库创建复制流用户su - postgrespsqlCREATE ROLE replica login replication encrypted password 'replica';修改文件(pg_hba.conf、postgresql.conf)vim /app/pgsql/data/pg_hba.conf末尾添加hos原创 2021-06-08 09:40:08 · 267 阅读 · 0 评论 -
postgresql主从切换
postgresql主从切换情况:主库配置文件丢失,无法回退,从库正常解决方案:从库提升为主库,原来主库进行基础备份pg_controldata查看状态/usr/pgsql-13/bin/pg_controldata /mnt/data/pgdata/从库状态注释postgresql.auto.conf的primary_conninfo升级为主库/usr/pgsql-13/bin/pg_ctl promote -D /mnt/data/pgdata/新从库操作参考:centos7-原创 2021-07-07 19:28:49 · 546 阅读 · 0 评论 -
postgresql数据类型
数据类型Name别名描述bigintint8有符号八字节整数bigserialserial8自增八字节整数bit [ (n) ]定长位串bit varying [ (n) ]varbit [ (n) ]变长位串booleanbool逻辑布尔值(真/假)box平面上的长方形盒子bytea二进制数据(“字节数组”)character [ (n) ]char [ (n) ]定长字符串character vary原创 2021-07-20 10:21:54 · 8603 阅读 · 0 评论 -
postgresql主键自增方法
建表后操作table_test :表名称id:字段名称CREATE SEQUENCE test_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;ALTER TABLE table_test ALTER COLUMN id SET DEFAULT nextval( 'test_id_seq' );原创 2021-06-09 11:28:10 · 66 阅读 · 0 评论 -
psql-timescaledb的使用
基于centos7-timescaledb插件安装一、添加扩展在想用插件的数据库中进行操作create extension timescaledb; 二、超表先创建一个普通的空表,需要有一个时间戳字段,用来分区(类型可以是timestamp、integer),假设表名为:hytest,字段为:time在空表的基础上,创建超表,分区时间为7day(可以自己调整,例如:“24 hours”)select create_hypertable('hytest', 'time', chunk_ti原创 2021-06-18 10:20:57 · 530 阅读 · 0 评论 -
centos7-postgresql12安装全过程
一、准备工作换源wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo清空yum&生成cache&updateyum clean all && yum makecache && yum update -y必要工具(看着加)yum install vim -y一些环境yum install centos-release-s原创 2021-06-07 20:39:53 · 295 阅读 · 0 评论 -
TimescaleDB——一些有用的sql语句
查询chunk信息--查询chunk信息SELECT chunk_name, range_start, range_end, is_compressed FROM timescaledb_information.chunks查看今日chunk--查看今日chunkSELECT show_chunks ( 'device_track', newer_than => now( ) :: DATE, older_than => now( ) :: DATE + 1 )压缩策略--开原创 2021-07-20 19:40:41 · 607 阅读 · 0 评论 -
postgresql、mysql循环插入
postgresqlDO $$ DECLAREv_idx INTEGER := 1;BEGIN while v_idx <= 1000000 loop v_idx = v_idx + 1; INSERT INTO "public"."ss" ( "a", "b", "c" ) VALUES ( 12341234, 12341234, 12341234 ); END loop;END $$;mysqldrop procedure IF EXISTS loopt原创 2021-07-20 13:44:07 · 368 阅读 · 0 评论 -
mysql数据库连接问题
Host is not allowed to connect to this MySQL server解决复制远程数据库到本地,链接本地时候报异常:Host is not allowed to connect to this MySQL server1、登录:mysql -u root -ppassword(也可以navicat直接F6)2、运行:use mysql;3、运行:update user set host = '%' where user = 'root';这一句执行完可能会报错,不用管原创 2021-05-11 08:38:48 · 74 阅读 · 0 评论