AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-124814

user8012596's questions

Martin Hope
user8012596
Asked: 2018-09-18 07:34:29 +0800 CST

Mysql子查询不识别子查询连接表字段

  • 1

我有一张三张桌子。主表是旅程数据,下一个表是警报表。journeydata 的主键是 journeydataID,它可以作为警报表中的键使用。接下来在警报表中有一个 fenceID,它是另一个表 fence 表的主键。下面我尝试运行一个子查询示例。我想要做的是将特定 journeydataID 的所有警报(如果它存在于单个字符串中)连接起来。但我不断收到错误 #1054 - “on 子句”中的未知列“alarmgroup.journeydataID”。接下来我要展示的任务是一个具有围栏名称值的警报。例如,如果有一个带有 fenceName 的 alarmName 的相关值显示为 alarmName(fenceName)。

SELECT journeydata.dateTime,
alarmDetails
FROM 
journeydata
LEFT JOIN
    ( SELECT GROUP_CONCAT(alarmType.alarmName) AS alarmDetails 
      FROM alarm     
      JOIN alarmType
      ON alarm.alarmTypeID = alarmType.alarmTypeID
      LEFT JOIN fence
      ON alarm.fenceID=fence.fenceID
      WHERE alarm.associateID=6
      GROUP BY alarm.journeydataID
    ) AS alarmgroup
    ON journeydata.journeydataID=alarmgroup.journeydataID

WHERe journeydata.associateID=6
mysql subquery
  • 1 个回答
  • 91 Views
Martin Hope
user8012596
Asked: 2017-06-30 09:55:05 +0800 CST

innodb 上大表的自动增量与复合主键

  • 7

我与 Rick James 就此进行了相当长时间的讨论,我们提出了使用复合键来替换 int 限制接近 20 亿的自动增量 pk 的想法。我的表将在几个月内轻松达到这个限制,因为我们每月都会捕获接近几亿的数据。下面是我的桌子的样子。关键表是gdata所以我使用 3 个字段来合成主表PRIMARY KEY (alarmTypeID,vehicleID,gDateTime)。然后我有另一个表称为警报表。两者之间的联系是一对多的。这意味着其中的一个数据gdata可以有零个或多个alarms与之相关。它们之间的联系是vehicleID和gDateTime。

CREATE TABLE `gdata` ( 
    `alarmTypeID` tinyint(4) NOT NULL DEFAULT '0', 
    `fleetID` smallint(11) NOT NULL, 
    `fleetGroupID` smallint(11) DEFAULT NULL, 
    `fleetSubGroupID` smallint(11) DEFAULT NULL, 
    `deviceID` mediumint(11) NOT NULL, 
    `vehicleID` mediumint(11) NOT NULL, 
    `gDateTime` datetime NOT NULL, 
    `insertDateTime` datetime NOT NULL, 
    `latitude` float NOT NULL, 
    `longitude` float NOT NULL, 
    `speed` smallint(11) NOT NULL
     -- (see full text) 
) ;
ALTER TABLE `gdata` 
    ADD PRIMARY KEY (`alarmTypeID`,`vehicleID`,`gDateTime`), 
    ADD KEY `gDateTime` (`gDateTime`), 
    ADD KEY `fleetID` (`fleetID`,`vehicleID`,`gDateTime`); 
COMMIT; 

这是报警表

CREATE TABLE `alarm` (
    `alarmTypeID` tinyint(4) NOT NULL, 
    `vehicleID` mediumint(9) NOT NULL, 
    `gDateTime` datetime NOT NULL, 
    `insertDateTime` datetime NOT NULL, 
    `alarmValue` varchar(5) NOT NULL, 
    `readWeb` enum('n','y') NOT NULL DEFAULT 'n', 
    `readWebDateTime` datetime NOT NULL, 
    `readMobile` enum('n','y') NOT NULL DEFAULT 'n', 
    `readMobileDateTim` datetime NOT NULL 
) ENGINE=InnoDB DEFAULT CHARSET=latin1; 

ALTER TABLE `alarm` 
    ADD PRIMARY KEY (`alarmTypeID`,`vehicleID`,`gDateTime`); 
COMMIT;

一切看起来都不错,但最近我在谷歌上搜索了一些相关主题,发现一些讨论https://www.quora.com/Is-it-a-bad-idea-to-have-a-primary-key-on- 3-or-more-columns反对复合主键,并且更愿意使用自动增量主要用于插入目的。有人可以对此进行更多说明以维护主键的复合键或返回自动增量吗?

mysql index
  • 2 个回答
  • 8952 Views
Martin Hope
user8012596
Asked: 2017-05-15 22:30:16 +0800 CST

Tokudb 错误和插件丢失导致 mysql 停止启动?

  • 0

我实际上已经安装了 percona mysql 并试图从 oracle mysql 迁移。我使用 innodb 已经有一段时间了。我听说并阅读了很多关于 tokudb 能够支持大型数据库等的信息。所以我尝试尝试了一下。它一直工作正常今天突然我运行 yum update 但它停止工作了。

下面是我的mysqld.cnf

# Percona Server template configuration

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#default-storage-engine=tokudb

最初我将 tokudb 作为我的默认存储,在更新后一切都乱七八糟,我评论了这一行 #default-storage-engine=tokudb 然后我的 mysql 才启动。

这是我运行 yum update 时更新的样子。

 Updating   : Percona-Server-shared-compat-57-5.7.18-14.1.el7.x86_64      1/10
  Updating   : Percona-Server-shared-57-5.7.18-14.1.el7.x86_64             2/10
  Updating   : Percona-Server-client-57-5.7.18-14.1.el7.x86_64             3/10
  Updating   : Percona-Server-server-57-5.7.18-14.1.el7.x86_64             4/10
 -------------
   *  The suggested mysql options and settings are in /etc/percona-server.conf.d/mysqld.cnf
   *  If you want to use mysqld.cnf as default configuration file please make backup of /etc/my.cnf
   *  Once it is done please execute the following commands:
 rm -rf /etc/my.cnf
 update-alternatives --install /etc/my.cnf my.cnf "/etc/percona-server.cnf" 200
 -------------
Percona Server is distributed with several useful UDF (User Defined Function) from Percona Toolkit.
Run the following commands to create these functions:
mysql -e "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'"
mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'"
mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'"
See http://www.percona.com/doc/percona-server/5.7/management/udf_percona_toolkit.html for more details
  Updating   : Percona-Server-tokudb-57-5.7.18-14.1.el7.x86_64             5/10
  Cleanup    : Percona-Server-tokudb-57-5.7.17-13.1.el7.x86_64             6/10
  Cleanup    : Percona-Server-server-57-5.7.17-13.1.el7.x86_64             7/10
  Cleanup    : Percona-Server-client-57-5.7.17-13.1.el7.x86_64             8/10
  Cleanup    : Percona-Server-shared-57-5.7.17-13.1.el7.x86_64             9/10
  Cleanup    : Percona-Server-shared-compat-57-5.7.17-13.1.el7.x86_64     10/10
  Verifying  : Percona-Server-tokudb-57-5.7.18-14.1.el7.x86_64             1/10
  Verifying  : Percona-Server-shared-57-5.7.18-14.1.el7.x86_64             2/10
  Verifying  : Percona-Server-server-57-5.7.18-14.1.el7.x86_64             3/10
  Verifying  : Percona-Server-shared-compat-57-5.7.18-14.1.el7.x86_64      4/10
  Verifying  : Percona-Server-client-57-5.7.18-14.1.el7.x86_64             5/10
  Verifying  : Percona-Server-server-57-5.7.17-13.1.el7.x86_64             6/10
  Verifying  : Percona-Server-shared-compat-57-5.7.17-13.1.el7.x86_64      7/10
  Verifying  : Percona-Server-tokudb-57-5.7.17-13.1.el7.x86_64             8/10
  Verifying  : Percona-Server-shared-57-5.7.17-13.1.el7.x86_64             9/10
  Verifying  : Percona-Server-client-57-5.7.17-13.1.el7.x86_64            10/10

Updated:
  Percona-Server-client-57.x86_64 0:5.7.18-14.1.el7
  Percona-Server-server-57.x86_64 0:5.7.18-14.1.el7
  Percona-Server-shared-57.x86_64 0:5.7.18-14.1.el7
  Percona-Server-shared-compat-57.x86_64 0:5.7.18-14.1.el7
  Percona-Server-tokudb-57.x86_64 0:5.7.18-14.1.el7

Complete!

这是我当前的 mysql.log。

2017-05-15T06:03:04.579874Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-05-15T06:03:04.581301Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.18-14) starting as process 2454 ...
2017-05-15T06:03:04.585394Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-05-15T06:03:04.585425Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-05-15T06:03:04.585433Z 0 [Note] InnoDB: Uses event mutexes
2017-05-15T06:03:04.585440Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-05-15T06:03:04.585449Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.7
2017-05-15T06:03:04.585460Z 0 [Note] InnoDB: Using Linux native AIO
2017-05-15T06:03:04.585733Z 0 [Note] InnoDB: Number of pools: 1
2017-05-15T06:03:04.585851Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-05-15T06:03:04.587208Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-05-15T06:03:04.591145Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-05-15T06:03:04.592947Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2017-05-15T06:03:04.602996Z 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
2017-05-15T06:03:04.603164Z 0 [Note] InnoDB: Setting file './ibdata1' size to 12 MB. Physically writing the file full; Please wait ...
2017-05-15T06:03:04.762580Z 0 [Note] InnoDB: File './ibdata1' size is now 12 MB.
2017-05-15T06:03:04.763040Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-05-15T06:03:05.221084Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-05-15T06:03:05.862770Z 0 [Note] InnoDB: Created parallel doublewrite buffer at /var/lib/mysql/xb_doublewrite, size 3932160 bytes
2017-05-15T06:03:05.946047Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-05-15T06:03:05.946134Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-05-15T06:03:05.946160Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2017-05-15T06:03:05.946222Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2017-05-15T06:03:06.096069Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2017-05-15T06:03:06.096267Z 0 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-05-15T06:03:06.296244Z 0 [Note] InnoDB: Doublewrite buffer created
2017-05-15T06:03:06.310384Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2017-05-15T06:03:06.310410Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2017-05-15T06:03:06.310601Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-05-15T06:03:06.354573Z 0 [Note] InnoDB: Foreign key constraint system tables created
2017-05-15T06:03:06.354637Z 0 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-05-15T06:03:06.387884Z 0 [Note] InnoDB: Tablespace and datafile system tables created.
2017-05-15T06:03:06.387937Z 0 [Note] InnoDB: Creating sys_virtual system tables.
2017-05-15T06:03:06.421245Z 0 [Note] InnoDB: sys_virtual table created
2017-05-15T06:03:06.421303Z 0 [Note] InnoDB: Creating zip_dict and zip_dict_cols system tables.
2017-05-15T06:03:06.454581Z 0 [Note] InnoDB: zip_dict and zip_dict_cols system tables created.
2017-05-15T06:03:06.454793Z 0 [Note] InnoDB: Waiting for purge to start
2017-05-15T06:03:06.504972Z 0 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.7.18-14 started; log sequence number 0
2017-05-15T06:03:06.505428Z 0 [Note] Plugin 'FEDERATED' is disabled.
2017-05-15T06:03:06.510037Z 0 [Warning] InnoDB: Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
mysqld: Table 'mysql.plugin' doesn't exist
2017-05-15T06:03:06.510134Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2017-05-15T06:03:06.511046Z 0 [Warning] InnoDB: Cannot open table mysql/gtid_executed from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
mysqld: Table 'mysql.gtid_executed' doesn't exist
2017-05-15T06:03:06.511091Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-05-15T06:03:06.514560Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2017-05-15T06:03:06.514581Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2017-05-15T06:03:06.536783Z 0 [Warning] CA certificate ca.pem is self signed.
2017-05-15T06:03:06.536866Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2017-05-15T06:03:06.537595Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2017-05-15T06:03:06.537649Z 0 [Note] IPv6 is available.
2017-05-15T06:03:06.537671Z 0 [Note]   - '::' resolves to '::';
2017-05-15T06:03:06.537754Z 0 [Note] Server socket created on IP: '::'.
2017-05-15T06:03:06.571570Z 0 [Warning] InnoDB: Cannot open table mysql/server_cost from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2017-05-15T06:03:06.571611Z 0 [Warning] Failed to open optimizer cost constant tables

2017-05-15T06:03:06.572621Z 0 [Warning] InnoDB: Cannot open table mysql/time_zone_leap_second from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2017-05-15T06:03:06.572655Z 0 [Warning] Can't open and lock time zone table: Table 'mysql.time_zone_leap_second' doesn't exist trying to live without them
2017-05-15T06:03:06.573327Z 0 [Warning] InnoDB: Cannot open table mysql/servers from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2017-05-15T06:03:06.573357Z 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
2017-05-15T06:03:06.582207Z 0 [Note] Event Scheduler: Loaded 0 events
2017-05-15T06:03:06.582530Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.18-14'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Percona Server (GPL), Release 14, Revision 2c06f4d
2017-05-15T06:03:06.582552Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check. 
2017-05-15T06:03:06.582560Z 0 [Note] Beginning of list of non-natively partitioned tables
2017-05-15T06:03:06.606414Z 0 [Note] End of list of non-natively partitioned tables
2017-05-15T06:10:22.125681Z 5 [Warning] InnoDB: Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2017-05-15T06:14:47.492149Z 8 [Warning] InnoDB: Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2017-05-15T06:16:05.397217Z 11 [Warning] InnoDB: Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.

最好的解决方案是什么,我应该放弃 tokudb 并继续使用 innodb,还是 percona 本身的错误?

mysql percona-server
  • 1 个回答
  • 404 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve