找到 4379 篇文章 关于 MySQL
221 次查看
要获取所有 MySQL 触发器,以下是语法:select trigger_schema, trigger_name from information_schema.triggers;让我们实现上述语法以获取所有触发器名称及其模式:mysql> select trigger_schema, trigger_name from information_schema.triggers;这将产生以下输出:+----------------+---------------------------------+ | TRIGGER_SCHEMA | TRIGGER_NAME | +----------------+---------------------------------+ | sys | sys_config_insert_set_user | | sys | sys_config_update_set_user | | business | binsertTrigger | | business ... 阅读更多
533 次查看
为此,请使用 BIT 数据类型。让我们首先创建一个表:mysql> create table DemoTable(binaryValue BIT(5)); Query OK, 0 rows affected (0.83 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(15); Query OK, 1 row affected (0.15 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;这将产生以下输出。现在您可以看到记录不可见:+-------------+ | binaryValue | +-------------+ | | | ... 阅读更多
147 次查看
要获取固定的浮点数据类型,请使用 DECIMAL()。这将解决不接受的问题。让我们首先创建一个表:mysql> create table DemoTable(Amount DECIMAL(10, 2)); Query OK, 0 rows affected (0.54 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values(2194848.90); Query OK, 1 row affected (0.65 sec) mysql> insert into DemoTable values(90309393.79); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values(8999999.68); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values(90900000.99); Query OK, 1 row affected (0.26 sec)使用 select 语句显示表中的所有记录:mysql> select ... 阅读更多
228 次查看
为此,请使用 DATEDIFF() 函数。让我们首先创建一个表:mysql> create table DemoTable(DOB datetime, CurrentDate datetime); Query OK, 0 rows affected (0.59 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('1995-01-21', CURDATE()); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('1998-11-01', CURDATE()); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable values('2000-10-24', CURDATE()); Query OK, 1 row affected (0.22 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;这将产生以下输出:+---------------------+---------------------+ | DOB ... 阅读更多
167 次查看
为此,请使用 ORDER BY FIELD() ASC。让我们首先创建一个表:mysql> create table DemoTable(Title varchar(100)); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('Java'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('C'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Python'); Query OK, 1 row affected (0.63 sec) mysql> insert into DemoTable values('MongoDB'); Query OK, 1 row affected (0.20 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;这将产生以下输出:+---------+ ... 阅读更多
618 次查看
要在 MySQL 中列出临时表列,让我们首先创建一个临时表。这是一个示例。我们创建了一个包含一些列的临时表,其中包含学生的详细信息:mysql> CREATE TEMPORARY TABLE DemoTable745 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100), StudentAge int, StudentAddress varchar(100), StudentCountryName varchar(20) ); Query OK, 0 rows affected (0.00 sec)以下是列出 MySQL 中临时表列的查询:mysql> show columns from DemoTable745;这将产生以下输出:-+--------------------+--------------+------+-----+---------+----------------+ | Field | Type ... 阅读更多
75 次查看
是的,我们可以将列值的所有数字替换为零,除了第一个数字。让我们首先查看一个示例并创建一个表:mysql> create table DemoTable744 (Number varchar(100)); Query OK, 0 rows affected (0.47 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable744 values('537737736252'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable744 values('989000099999'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable744 values('343225666666664533'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable744 values('4322111899494'); Query OK, 1 row affected (0.15 sec)显示表中的所有记录 ... 阅读更多
1K+ 次查看
要仅保留前两个字符并删除其余字符,请使用 SUBSTRING()。让我们首先创建一个表:mysql> create table DemoTable743 (SubjectName varchar(100)); Query OK, 0 rows affected (0.54 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable743 values('MySQL'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable743 values('Java'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable743 values('MongoDB'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable743 values('Python'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable743 values('Data Structure'); Query OK, 1 row affected (0.68 ... 阅读更多
1K+ 次查看
为此,请使用 REGEXP。让我们首先创建一个表:mysql> create table DemoTable(SubjectCode varchar(100)); Query OK, 0 rows affected (0.89 sec)使用 insert 命令在表中插入一些记录。记录包含文本、数字和特殊字符:mysql> insert into DemoTable values('Java899@22'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('C#'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('~Python232'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('MongoDB%'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('C123456'); Query OK, 1 row affected (0.37 sec)显示所有 ... 阅读更多
浏览量:192
首先,让我们创建一个表:mysql> create table DemoTable742 (Value varchar(100)); Query OK, 0 rows affected (2.91 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable742 values('632535MIT'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable742 values('US%UK'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable742 values('56%78'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable742 values('%_1234'); Query OK, 1 row affected (0.09 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable742;这将产生以下输出:-+-----------+ | Value | ... 阅读更多