为 MySQLi 找到 4219 篇文章
412 次浏览
若要阻止用户访问特定架构,需要使用删除命令。以下是语法:DELETE FROM mysql.db WHERE Db IN("yourSpecificSchema", "yourSpecificSchema\_%") AND User = "yourUserName" AND Host = "yourHostName";让我们通过上述语法实现阻止用户访问特定架构。首先,让我们从 MySQL.user 表中显示所有用户和主机。mysql> select user, host from MySQL.user;这将产生以下输出:+------------------+-----------+ | user | host | +------------------+-----------+ | Bob | % ... 阅读更多
568 次浏览
对于条件 MySQL 查询,可以在存储过程中使用 IF ELSE 概念。让我们首先创建一个表:mysql> create table DemoTable1 ( Id int ); 查询已提交,0 行受影响(0.62 秒)使用插入命令在表中插入一些记录:mysql> insert into DemoTable1 values(10); 查询已提交,1 行受影响(0.19 秒) mysql> insert into DemoTable1 values(20); 查询已提交,1 行受影响(0.12 秒) mysql> insert into DemoTable1 values(30); 查询已提交,1 行受影响(0.12 秒)使用选择语句显示表中的所有记录:mysql> select *from DemoTable1;这将产生以下输出: ... 阅读更多
219 浏览量
使用 CASE 语句是一个不错的选择。不要使用 UNION。我们首先创建一个表 −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ShippingDate datetime ); 查询成功,0 行受影响 (0.63 秒)使用插入命令向表中插入一些记录 −mysql> insert into DemoTable(ShippingDate) values('2019-04-21'); 查询成功,1 行受影响 (0.17 秒) mysql> insert into DemoTable(ShippingDate) values('2019-01-01'); 查询成功,1 行受影响 (0.13 秒) mysql> insert into DemoTable(ShippingDate) values('2019-05-11'); 查询成功,1 行受影响 (0.16 秒) mysql> insert into DemoTable(ShippingDate) values('2018-12-31'); 查询成功,1 行... 了解更多信息
355 浏览量
可以使用子查询。语法如下 −SELECT * FROM ( SELECT * FROM yourTableName ORDER BY yourIdColumnName DESC LIMIT 3 ) anyAliasName ORDER BY yourIdColumnName;让我们首先创建一个表 −mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(100) ); 查询 OK, 0 行受影响 (0.60 秒)使用插入命令向表中插入一些记录 −mysql> insert into DemoTable(ClientName) values('Larry'); 查询 OK, 1 行受影响 (0.18 秒) mysql> insert into DemoTable(ClientName) values('Chris'); 查询 OK, 1 行受影响 (0.12 秒) mysql> insert into DemoTable(ClientName) values('Bob'); 查询 OK, 1 行受影响 (0.10 秒) mysql> insert into DemoTable(ClientName) values('David'); 查询 OK, 1 行受影响 (0.12 秒) mysql> insert into DemoTable(ClientName) values('Carol'); 查询 OK, 1 行受影响 (0.10 秒) mysql> insert into DemoTable(ClientName) values('Robert'); 查询 OK, 1 行受影响 (0.19 秒) mysql> insert into DemoTable(ClientName) values('Sam'); 查询 OK, 1 行受影响 (0.17 秒) mysql> insert into DemoTable(ClientName) values('Mike'); 查询 OK, 1 行受影响 (0.12 秒)使用 select 语句显示表中的所有记录 −mysql> select *from DemoTable;这会生成... 了解更多信息
2K+ 浏览量
要在 group_concat() 函数中使用新行分隔符,请遵循以下语法 −select group_concat(concat_ws(' ', yourColumnName1, yourColumnName2) SEPARATOR "\r") from yourTableName;让我们首先创建一个表 −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20), LastName varchar(20) ); 查询成功,0 行受影响 (0.67 秒)使用插入命令向表中插入一些记录 −mysql> insert into DemoTable(FirstName, LastName) values('John', 'Smith'); 查询成功,1 行受影响 (0.10 秒) mysql> insert into DemoTable(FirstName, LastName) values('David', 'Miller'); 查询成功,1 行受影响 (0.14 秒) mysql> insert into DemoTable(FirstName, LastName) values('John', 'Doe'); ... 了解更多信息
121 浏览量
您可以为此使用MySQL中的CONCAT()函数。 我们首先创建一个表−mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientFirstName varchar(20), ClientLastName varchar(20) ); 查询正常,0行受影响(0.50秒)使用插入命令在表中插入一些记录−mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('John', 'Smith'); 查询正常,1行受影响(0.15秒) mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('John', 'Miller'); 查询正常,1行受影响(0.12秒) mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('Carol', 'Taylor'); 查询正常,1行受影响(0.13秒) mysql> insert into ... 了解更多
4千+看过
首先,你需要启用innodb_print_all_deadlocks。 以下是语法 −set global innodb_print_all_deadlocks=1;在执行以上语句后, 让我们执行以下语法以显示所有死锁日志 −show engine innodb status;让我们实现以上语法 −mysql> set global innodb_print_all_deadlocks=1; 查询正常,0行受影响(0.00秒) mysql> show engine innodb status;这将产生以下输出 −+--------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Type | Name | Status ... 了解更多
272看过
首先我们创建一个表 −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value char(1) ); 查询成功,0 行受影响 (0.66 秒)使用插入命令向表中插入一些记录 −mysql> insert into DemoTable(Value) values('X'); 查询成功,1 行受影响 (0.20 秒) mysql> insert into DemoTable(Value) values('Y'); 查询成功,1 行受影响 (0.09 秒) mysql> insert into DemoTable(Value) values('X'); 查询成功,1 行受影响 (0.30 秒) mysql> insert into DemoTable(Value) values('X'); 查询成功,1 行受影响 (0.07 秒) mysql> insert into DemoTable(Value) values('Y'); 查询成功,1 行 ... 了解更多
136 次浏览
要为类型设置过滤器,可以使用以下语法 −SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'yourDataTypeName';让我们实现上述语法以仅显示字段类型为文本的字段 −mysql> SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'text';这将生成以下输出 −+---------------------------------------------+--------------------------------+ | TABLE_NAME | COLUMN_NAME | +---------------------------------------------+--------------------------------+ | COLUMNS ... 了解更多
1 千次浏览
要按组列出所有行,可以使用 GROUP_CONCAT()。首先我们创建一个表 −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(20), Value varchar(100) ); 查询成功,0 行受影响 (0.62 秒)使用插入命令向表中插入一些记录 −mysql> insert into DemoTable(Name, Value) values('John', 'John'); 查询成功,1 行受影响 (0.15 秒) mysql> insert into DemoTable(Name, Value) values('Carol', 'Carol'); 查询成功,1 行受影响 (0.21 秒) mysql> insert into DemoTable(Name, Value) values('John', 'Works'); 查询成功,1 行受影响 (0.13 秒) mysql> insert ... 了解更多