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-21546

simplifiedDB's questions

Martin Hope
simplifiedDB
Asked: 2017-04-05 05:37:46 +0800 CST

MySQL 5.7 中的 Log_Slave_Updates 在 Linux 中复制失败吗?

  • 0

我在 RHEL 中为 2 个节点设置了 Master Master 复制设置。一个服务器充当另一个服务器(也是 Master 和 Slave)的 Master 和 slave 假设 A 服务器和 B 服务器

我在 B 服务器上启用了 log_slave_updates,以便从主服务器(服务器 A)接收的所有语句都应该记录到服务器 B 的二进制日志中。

我期待复制,会失败,因为:

         1. Created a Table on Server A.
         2. It get replicated to Server B.

现在,从属 B 的二进制日志将转到服务器 A,这应该会中断复制,提示“表已存在”。但它没有

这里的逻辑是什么?

编辑部分:

  1. 两台服务器上的服务器ID不同
mysql replication
  • 1 个回答
  • 261 Views
Martin Hope
simplifiedDB
Asked: 2015-11-27 02:51:28 +0800 CST

Mysql 复制中二进制日志文件的大小

  • 0

我在 Linux 服务器中有一个主服务器复制设置。

主配置详细信息:

 MySQL version is 5.1 and replication mode is MIXED type.

从站配置详细信息:

 MySQL version is 5.6

如果我插入单个记录,那么它将被复制到从属。

当我运行脚本在 master 插入数千条记录时,它不会被复制。

当我看到二进制日志文件的大小时,它是 908 MB,当我看到中继日志文件的大小时,它是 560 KB。

二进制日志文件的大小是否重要?
或者这可能是什么原因。

以下是主cnf详细信息:

  [mysqld]

  datadir=/var/lib/mysql
  socket=/var/lib/mysql/mysql.sock
  user=mysql
  # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    bind-address = #master IP# ( not showing here )
    port=3306
    wait_timeout=90
    net_read_timeout=90
    connect_timeout=90
    max_connections=100
    lower_case_table_names=1
    log-bin=mysql-bin
    binlog_format=MIXED
    server-id=1

[mysqld_safe]
     log-error=/var/log/mysqld.log
     pid-file=/var/run/mysqld/mysqld.pid
mysql replication
  • 1 个回答
  • 2749 Views
Martin Hope
simplifiedDB
Asked: 2015-08-18 02:51:05 +0800 CST

FLUSH TABLE:无法执行给定的命令,因为您有活动的锁定表 mysql

  • 2

如果我一个一个地执行这些查询,除了第一个之外都失败:

查询1:

flush table tablename1 with read lock;

作品

查询2:

flush table tablename2 with read lock;

错误:无法执行给定的命令,因为您有活动的锁定表 mysql

如果我按以下方式执行,它将起作用:

询问:

flush table tablename1,tablename2 with read lock;

里面发生了什么?

mysql mysql-5.6
  • 2 个回答
  • 7346 Views
Martin Hope
simplifiedDB
Asked: 2015-06-27 04:12:32 +0800 CST

具有多个实例 MySQL 的单个从属服务器上的多源复制

  • 0

我在一台服务器 A(从 S)上有 1 个 mysql 5.6 实例

1 Mysql安装在服务器B(Master M1)

1 MySql 安装在服务器 C ( Master M2 )

At Slave end :

I have created one more instance by creating one more my.conf file from existing my.cnf in Slave and placed it in "C:\Program Files (x86)\MySQL\MySQL Server 5.6\my.conf" which looks like this : 

 # MySQL Server Instance Configuration File
 # ----------------------------------------------------------------------
 # Generated by the MySQL Server Instance Configuration Wizard
 #
 #
 # Installation Instructions
 # ----------------------------------------------------------------------
 #
 # On Linux you can copy this file to /etc/my.cnf to set global options,
 # mysql-data-dir/my.cnf to set server-specific options
 # (@localstatedir@ for this installation) or to
 # ~/.my.cnf to set user-specific options.
 #
 # On Windows you should keep this file in the installation directory 
      # of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
    # make sure the server reads the config file use the startup option 
 # "--defaults-file". 
 #
 # To run run the server from the command line, execute this in a 
 # command line shell, e.g.
 # mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
 #
 # To install the server as a Windows service manually, execute this in a 
 # command line shell, e.g.
 # mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL              Server X.Y\my.ini"
 #
 # And then execute this in a command line shell to start the server, e.g.
 # net start MySQLXY
 #
 #
 # Guildlines for editing this file
 # ----------------------------------------------------------------------
 #
 # In this file, you can use all long options that the program supports.
 # If you want to know the options a program supports, start the program
 # with the "--help" option. 
 #
 # More detailed information about the individual options can also be
 # found in the manual.
 #
 #
 # CLIENT SECTION
 # ----------------------------------------------------------------------
 #
 # The following options will be read by MySQL client applications.
 # Note that only client applications shipped by MySQL are guaranteed
 # to read this section. If you want your own MySQL client program to
 # honor these values, you need to specify it as an option during the
 # MySQL client library initialization.
 #
  [client]

     port=3306
     #ssl-ca=ca.pem
     #ssl-cert=client-cert.pem
     #ssl-key=client-key.pem

    [mysql]

      default-character-set=utf8


  # SERVER SECTION
  # ----------------------------------------------------------------------
  #
  # The following options will be read by the MySQL Server. Make sure that
  # you have installed the server correctly (see above) so it reads this 
  # file.
  #
[mysqld]
  server-id=1
  log-bin=mysql-bin
  binlog_format=ROW
  # The TCP/IP Port the MySQL Server will listen on
  port=3306

   innodb_file_per_table = 1
   innodb_file_format = barracuda
   max_allowed_packet = 256M
   innodb_lock_wait_timeout=120
   transaction-isolation = READ-COMMITTED
   interactive_timeout=300
   wait_timeout=300

 #Path to installation directory. All paths are usually resolved relative        to this.
   basedir="C:/Program Files (x86)/MySQL/MySQL Server 5.6/"

#Path to the database root
   datadir="C:/ProgramData/MySQL/MySQL Server 5.6/Data/"

# The default character set that will be used when a new schema or table is
# created and no character set is defined
   character-set-server=utf8

# The default storage engine that will be used when create new tables when
   default-storage-engine=INNODB

# The default storage engine that will be used for temporary tables
   default-tmp-storage-engine=INNODB

# Set the SQL mode to strict
   sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
 max_connections=1510

# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
   query_cache_size=164M

# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
    table_cache=3020

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
    tmp_table_size=30M


# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
    thread_cache_size=64

#*** MyISAM Specific options

# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
     myisam_max_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
      myisam_sort_buffer_size=30M

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
      key_buffer_size=252M

# Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
      read_buffer_size=64K
      read_rnd_buffer_size=256K

# This buffer is allocated when MySQL needs to rebuild the index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
     sort_buffer_size=256K


#*** INNODB Specific options ***


# Use this option if you have a MySQL server with InnoDB support enabled
# but you do not plan to use it. This will save memory and disk space
# and speed up some things.
#skip-innodb

# Additional memory pool that is used by InnoDB to store metadata
# information.  If InnoDB requires more memory for this purpose it will
# start to allocate it from the OS.  As this is fast enough on most
# recent operating systems, you normally do not need to change this
# value. SHOW INNODB STATUS will display the current amount used.
    innodb_additional_mem_pool_size=11M

# If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
    innodb_flush_log_at_trx_commit=1

# The size of the buffer InnoDB uses for buffering log data. As soon as
# it is full, InnoDB will have to flush it to disk. As it is flushed
# once per second anyway, it does not make sense to have it very large
# (even with long transactions).
     innodb_log_buffer_size=5M

# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you set this the less disk I/O is needed to
# access data in tables. On a dedicated database server you may set this
# parameter up to 80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical memory may
# cause paging in the operating system.  Note that on 32bit systems you
# might be limited to 2-3.5G of user level memory per process, so do not 
# set it too high.
    innodb_buffer_pool_size=489M

# Size of each log file in a log group. You should set the combined size
# of log files to about 25%-100% of your buffer pool size to avoid
# unneeded buffer pool flush activity on log file overwrite. However,
# note that a larger logfile size will increase the time needed for the
# recovery process.
  innodb_log_file_size=98M

# Number of threads allowed inside the InnoDB kernel. The optimal value
# depends highly on the application, hardware as well as the OS
# scheduler properties. A too high value may lead to thread thrashing.
  innodb_thread_concurrency=8


 [mysqld1]

  basedir ="C:\Program Files (x86)\MySQL\MySQL Server 5.6"

  port = 3307

  enable-named-pipe

  socket = mypipe1


 [mysqld2]

   basedir ="C:\Program Files (x86)\MySQL\MySQL Server 5.6"

   port = 3308

   enable-named-pipe

   socket = mypipe2

现在我想将 M1 和 M2 都复制到 slave s。我应该怎么做?

windows replication
  • 1 个回答
  • 522 Views
Martin Hope
simplifiedDB
Asked: 2015-06-26 23:07:29 +0800 CST

对于多个 mysql 实例,存在一个时需要重新下载吗?

  • 1

我需要在同一台服务器上安装多个 Mysql 实例。我浏览过很多链接,但我在这里感到困惑:

What i have : MySQL 5.6 is already installed on my windows server A.
Installed at : "C:\Program Files (x86)\MySQL\MySQL_Server_5.6\"

Problem :   For multiple instances , do i need to download and install new mysql(either same or higher version) on server A ?

OR
  should i just copy existing my.conf file in new folder and then change its port number and then done.

我自己的分析继续全新安装,但请确认。

windows mysql-5.6
  • 2 个回答
  • 804 Views
Martin Hope
simplifiedDB
Asked: 2015-06-02 23:41:56 +0800 CST

在不同数据库中的同一服务器中进行复制。mysql 5.6

  • 3

我有的 :

  • 一台带有 MySQL 5.6 Server 实例的 Windows 机器。
  • 两个数据库名为 test 和 test2。
  • Test数据库有一个名为activity列的表id和class

我需要的 :

  • test.activity将表复制到test2数据库的条件是Test.activity.class = 'B'.

我知道如何在不同的服务器上进行复制。但不适用于不同数据库中的同一服务器。我已经检查了这个链接,但它没有提供足够的信息。

mysql replication
  • 5 个回答
  • 6439 Views
Martin Hope
simplifiedDB
Asked: 2014-09-17 05:41:14 +0800 CST

根据子查询的输出更新表的特定记录(sql server)

  • 0

有这个查询产生以下输出:

select sec.site,sec.Name,sec.Freq from
( select Name from sec group by name having count(Freq) > 3)as dt
inner join sec on dt.Name = sec.Name
where sec.Freq like '%MUF2900%' ;


site    Name            Freq
S003   sct003a       MUF2900_26
S003   sct003a       MUF2900_26 
S003   sct003a       MUF2900_26
S034   sct034a       MUF2900_26
S034   sct034a       MUF2900_26
S034   sct034a       MUF2900_26

现在我必须根据上述查询的输出更新我的另一个表名测试。表测试当前包含以下记录(更新前):

 site      cell       ID
 S003      09M00011   1019581
 S003      09M00012   1019582
 S003      09M00013   1019583
 S003      29M00011   1019581
 S003      29M00012   1019582
 S003      29M00013   1019583
 S034      09M00011   1016581
 S034      09M00011   1016582
 S034      09M00011   1016583

 now for site S003 , ID for for cell starting from 09 and 29 are same ,so i need to update the ID for 29  i.e the unit place of ID should be incremented by 10 , like following..

必需的 :

  Site      cell       ID
 S003      09M00011   1019581
 S003      09M00012   1019582
 S003      09M00013   1019583
 S003      29M00011   10195811
 S003      29M00012   10195812
 S003      29M00013   10195813
 S034      09M00011   1016581
 S034      09M00011   1016582
 S034      09M00011   1016583

我有很多这样的记录。

注意:S034 没有从 29 开始的单元格,所以它的 ID 不需要更新。

我尝试过的和我感到困惑的地方是:

 update Test set ID = (how to do this ??)
  where Test.site = (select sec.site,sec.Name,sec.Freq from
( select Name from sec group by Name having count(Freq) > 3)as dt
inner join sec on dt.Name = Sec.Name
where sec.Freq like '%MUF2900%') where cell like '29M%';

我应该怎么做。我需要为此制作光标吗??

sql-server t-sql
  • 2 个回答
  • 655 Views
Martin Hope
simplifiedDB
Asked: 2014-09-02 12:50:16 +0800 CST

根据不同条件插入数据

  • -4

虽然,我努力使问题易于理解,但我仍然不知道出了什么问题。不管怎样,我正在努力使它更紧凑

我现在只有下表:

在列号中,JU 表示 Junior,SU 表示 Senior

 name         number            fin
------------------------------------
 paul        JU00011          100401
 paul        JU00012          100402
 paul        JU00012          100403
 maul        JU00021          100641
 maul        JU00022          100642
 paul        SU00012          100401
 paul        SU00012          100402
 paul        SU00012          100403

Now in this table , fin for paul are same ( for junior ans senior ).
i need to make an update in this table 
for example :If paul is coming under two numbers (i.e JU and SU) and have same fin number,
so i want to update fin , when 2 fin are same and belongs to same name and is coming under Junior category and Senior Category 

 Final Result :
name         number            fin
------------------------------------
 paul        JU00011          100401
 paul        JU00012          100402
 paul        JU00012          100403
 maul        JU00021          100641
 maul        JU00022          100642
 paul        SU00012          1004011
 paul        SU00012          1004012
 paul        SU00012          1004013

  Such type of records are more.
sql-server t-sql
  • 2 个回答
  • 123 Views
Martin Hope
simplifiedDB
Asked: 2014-01-09 23:19:04 +0800 CST

在 mysql 中 24 小时后自动更新列

  • 3

我有一个表 T1 列:

Name      State             time
mon         1          2014-01-09 11:23:00
tue         0          2014-01-07 14:40:00
wed         2          2014-01-08 09:23:00 
thu         0          2014-01-09 12:23:00   

现在我想安排一个事件或开发一个触发器(如果可能的话),如果任何状态是 0/2 并且它的时间比当前时间超过 24 小时,那么它应该更新为 1。

例如在上表中,Tue 的状态为 0,时间超过 24 小时,因此 state 应更新为 1,同样适用于 wed,但不适用于 thu。

我经历了很多问题,例如:

https://stackoverflow.com/questions/17387802/how-to-auto-update-mysql-after-timestamp-field-expierd

https://stackoverflow.com/questions/12421756/how-to-update-table-after-a-certain-time-interval

但我还不明白,如何解决我的问题

mysql mysql-5.5
  • 1 个回答
  • 34310 Views
Martin Hope
simplifiedDB
Asked: 2013-12-07 00:41:01 +0800 CST

在 mysql/oracle 中发出删除/更新命令之前发出警告,然后执行

  • 0

mysql / oracle 中是否有任何实用程序/功能可以防止我错误地发出一些删除/更新命令,必须在 command_line* (如果可能在 ubuntu 中)提示一条消息,询问是否“您确定运行此命令”,如果是,则删除/update 命令会执行吗?

我已经用谷歌搜索了这个,但没有为此提供具体的解决方案。我也尝试了 SOURCE,但这并不是我想要的。

有人对此有任何想法吗?

如果我要对 > 100 000 条记录执行更新命令,应该会出现一个提示,询问“你真的要运行吗?”,就像在 Unix 中,如果我们使用 rm 文件名,它会询问你是否确定要删除?

mysql oracle
  • 2 个回答
  • 2047 Views
Martin Hope
simplifiedDB
Asked: 2013-12-04 03:44:14 +0800 CST

在 mysql 中插入期间在 datetime 列中添加

  • 1

我有一个包含以下 5 列的表格。时间戳是时间日期相关列的数据类型:

 Region     event_time     start_time     mid_time   end_time
 India   2013-11-03 13:00:00        
 America
 Holland
Switzerland    

我有来自上列数据以特定时间间隔出现的来源..现在插入时我需要添加时间。

对于前。如果在 csv 文件中我有 2013-11-03 13:00:00 的 event_time,那么对于印度时间在插入之前添加 5:30(由于格林威治标准时间)..最终插入的值应该是 2013-11-03 18 :30:00 ..同样适用于其余地区和日期时间列..我应该怎么做...此外夏令时将包括其他有此功能的地区

我尝试了 adddate 和 addtime 函数..但这不起作用...我尝试在插入后进行更新,但这不是我想要的解决方案...有什么帮助吗??

mysql-5.5
  • 1 个回答
  • 200 Views
Martin Hope
simplifiedDB
Asked: 2013-11-19 05:29:54 +0800 CST

格式为 Varchar 时 MySQL 中的日期时间差异

  • 1

我在一个表中有两列:STOP和START,类型为varchar。

我想在两列之间有所区别,我正在使用:

SELECT DATEDIFF(stop, start) AS difference from T1;

null由于不同的数据类型,它给了我。

为了测试,我还尝试了:

SELECT STR_TO_DATE('5/16/2011 20:14 PM', '%c %e %Y %H:%i:%s');

它也在给予null。

我该怎么办?我有n不同格式的数据和时间。

在此处输入图像描述

mysql mysql-5.5
  • 1 个回答
  • 2198 Views
Martin Hope
simplifiedDB
Asked: 2013-10-19 05:55:33 +0800 CST

Mysql中的过程和自动化

  • 0

我有一个包含这些列的表,这些值以 n 分钟的固定间隔从 csv 文件进入这些表(通过 cron load infile 命令):

 ID (PK)        status      first      last     value
 1                Q          12         15       low
 2                Q          12         15       low
 3                O          12         15       High

现在每当下一个数据到来时,它应该首先检查表中是否存在 ID,如果存在则更新该 ID 的相应字段,如果有新 ID 到来,它只需插入数据。

为此,我创建了一个程序:

     create procedure test.testproc (IN no int , IN status varchar(10))     
     begin if exists (select id from test.testproc where id = no)
     then 
     update baseline set status=status where id=no;
     else insert into  tname(id,status) value(no,status);
     end if;
     end$$

现在我想知道的是:

  1. 我应该为此创建两个表,即一个是临时表和一个主表吗?** 我 100% 困惑在这里我应该做什么

  2. 我应该如何自动化所有这些 ie 数据来自 csv 文件,然后我的加载 infile 脚本运行,然后我的上述过程应该执行并检查如果 ID 已经存在它会简单地更新否则它会插入。

或者,如果您有任何其他过程,请告诉

mysql stored-procedures
  • 1 个回答
  • 403 Views
Martin Hope
simplifiedDB
Asked: 2013-09-19 02:52:26 +0800 CST

根据条件检索数据

  • 0

我有 2 个表,TA并且TB:

TA
--------
id  name
1   a
2   b
3   c
4   d
5   e
6   f

TB
--------
id  p_id  name
1   1     a
2   1     b
3   1     c
4   2     a
5   2     b
6   2     d

我需要:如果p_id = 1那么:

id  name match
1   a    1 
2   b    1
3   c    1
4   d    0
5   e    0
6   f    0

如果p_id = 2那么:

id  name match
1   a    1 
2   b    1
3   c    0
4   d    1
5   e    0
6   f    0
mysql oracle
  • 1 个回答
  • 562 Views
Martin Hope
simplifiedDB
Asked: 2013-09-18 00:15:15 +0800 CST

auto_increment 如何在 mysql 中工作

  • 1

我在这里很困惑,我创建了一个表并有 2 列 id 和 name。

现在 id 是主键,而不是 null 和自动递增。

假设我开火:insert into table (name) values('test');

这会给我:

1  | test

现在如果我开火:alter table table_name auto_increment = 5;

这将在下一次插入时用 5 填充 id。

现在,如果我删除 id =5 的值并再次重新插入:insert into table (name) values ('test2');

它给了我:

 6  | test2

为什么它不再给我5?

另外,我们不可能在 MySql 中将现有的 auto_increment 值重置为所需的值吗?

mysql-5.5
  • 1 个回答
  • 1192 Views
Martin Hope
simplifiedDB
Asked: 2013-09-06 22:14:16 +0800 CST

没有值的内部连接与where子句?

  • 1

我有 2 张桌子:

表格1

父(varchar)子(varchar)

表2

C1(varchar) PC (varchar)

样本数据:

在此处输入图像描述

要求 - 我需要 Table2.C1 列的 Table2.PC = Table1.Child 值,但子值必须与 Table1.Parent 的值不同。

我在mysql中使用以下查询:

select distinct(C1),Child,PC 
  from Table2 inner join Table1 
    on Table2.PC=Table1.Child 
 where Table1.Child not in (select Parent from Table1);

它给出了空集,但 Child 中的值与 PC 中的值相同,但 Parent 中没有。

我哪里错了?

mysql join
  • 3 个回答
  • 4012 Views
Martin Hope
simplifiedDB
Asked: 2013-07-12 03:58:04 +0800 CST

需要找出不在所有部门的员工数量

  • 0

我有一个表 T1,它有两列empname,department

每个 emp 必须在 37 部门,但也有一些员工在 37 部门以下。

我需要找到不在所有 37 个部门中的 emp 的名称。

我正在使用查询:

select empname from T1 having count (department) < 37;

但它没有给我想要的输出。

mysql group-by
  • 1 个回答
  • 946 Views
Martin Hope
simplifiedDB
Asked: 2013-05-29 22:58:24 +0800 CST

在 MySQL 中的特定时间到期后更新列

  • 3
  1. 我有一个表,其中有一个名为state(int(2))and的列modify_time(time_stamp更新当前时间戳)。

  2. 0我有一个更新触发器,它根据某些条件将状态列的值更改为。

  3. 我想将statecolumn的值设置为124 小时后modify_time,如果它仍然是0。

  4. 我尝试了以下方法进行测试:

    CREATE EVENT myevent1 
     ON SCHEDULE AT current_timestamp + interval 1 minute 
     DO UPDATE test.mytabletable SET state = 0;
    

这并没有做任何事情。有没有替代方法?

mysql trigger
  • 2 个回答
  • 18121 Views
Martin Hope
simplifiedDB
Asked: 2013-05-06 23:25:32 +0800 CST

当列的值从 null 更改为 1 时,触发器不会运行

  • 4

我有这个触发器:

delimiter $$

create trigger tr 
after update on t1
for each row
begin

  if new.col1 !=old.col1 
    then update t2 set col2 =1 where t2.col3=t1.col3;
  end if;

end

$$

此触发器在col1' 的值从 0 更改为 1 时起作用,但当其从 null 更改为 1 时,触发器不会对t2.

我只是想知道为什么会这样。我知道 null 是不同的,但我只是在比较值。

我已经解决了我的问题new.col1 =1。

mysql datatypes
  • 4 个回答
  • 7704 Views
Martin Hope
simplifiedDB
Asked: 2013-04-26 23:35:27 +0800 CST

触发器是否可以使用已删除的值更新表中的行?

  • 1

我有一个触发器,它在插入行后更新不同表中的列:

mysql>delimiter $$

mysql> create trigger status

 after insert on table2

 FOR EACH ROW 

 BEGIN update

 table1 inner join table2

 ON table1.id=table2.id 

 set table1.state=0 ;

现在我想table1.state=1在删除相同的值时重置。这可能吗?

mysql trigger
  • 1 个回答
  • 10186 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