找到 4379 篇文章 适用于 MySQL
220 次查看
为此,请使用 SET yourColumnName = NULL,如下面的语法所示 -update yourTableName set yourColumnName=NULL where yourColumnName=yourValue;让我们首先创建一个表 -mysql> create table DemoTable1914 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Code varchar(20) )AUTO_INCREMENT=1001; Query OK, 0 rows affected (0.00 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1914(Code) values('John101'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1914(Code) values('234David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1914(Code) values('100_Mike'); Query OK, 1 row affected (0.00 sec)显示表中所有记录使用 select ... 阅读更多
162 次查看
要追加 000,请使用 ZEROFILL 的概念。让我们首先创建一个表 -mysql> create table DemoTable1913 ( Code int(4) ZEROFILL AUTO_INCREMENT NOT NULL, PRIMARY KEY(Code) ); Query OK, 0 rows affected (0.00 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1913 values(1); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1913 values(2); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1913 values(3); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1913 values(4); Query OK, 1 row affected (0.00 sec)显示表中所有记录 ... 阅读更多
169 次查看
为此,请使用 ORDER BY 以及 LIMIT。让我们首先创建一个表,其中包含一个包含用户 ID、登录时间和名称的列 -mysql> create table DemoTable1911 ( UserId int, UserLoggedInTime time, UserName varchar(20) ); Query OK, 0 rows affected (0.00 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1911 values(100, '7:32:00', 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1911 values(101, '5:00:00', 'David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1911 values(102, '6:10:20', 'Mike'); Query OK, 1 row affected (0.00 ... 阅读更多
508 次查看
为此,您可以使用 CASE WHEN 语句。让我们首先创建一个表 -mysql> create table DemoTable1910 ( FirstName varchar(20), Marks int ); Query OK, 0 rows affected (0.00 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1910 values('Chris', 45); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1910 values('David', 85); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1910 values('Chris', 55); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1910 values('Chris', 98); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1910 values('David', ... 阅读更多
169 次查看
要返回数据库列表,语法如下 -select schema_name as anyAliasName from information_schema.schemata;以下是返回 MySQL 中数据库列表的查询 -mysql> select schema_name as DatabaseName from information_schema.schemata;这将产生以下输出 -+---------------------------+ | DatabaseName | +---------------------------+ | mysql | | information_schema | | performance_schema | | sys | | business | | sample | | hello | | test | | mybusiness | | databasesample | | schemasample | | universitydatabase | | education | | mydatabase | | database1 | | sampledatabase | | test3 | | javadatabase2 | | javasampledatabase | | rdb | | onetomanyrelationship | | webtracker | | web | | commandline | | hb_student_tracker | | bothinnodbandmyisam | | customertracker | | tracker | | demo | | customer_tracker_database | | login | | onlinebookstore | | customer-tracker | | web_tracker | | instant_app | | 1233 | +---------------------------+ 36 rows in set (0.00 sec)
428 次查看
为此,您只需要使用 SET 命令一次。让我们首先创建一个表 -mysql> create table DemoTable1909 ( Id int NOT NULL, FirstName varchar(20), LastName varchar(20) ); Query OK, 0 rows affected (0.00 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1909 values(101, 'John', 'Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1909 values(102, 'John', 'Doe'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1909 values(103, 'Adam', 'Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1909 values(104, 'David', 'Miller'); Query ... 阅读更多
727 次查看
让我们首先创建一个表 -mysql> create table DemoTable1908 ( Code text ); Query OK, 0 rows affected (0.00 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1908 values('MySQL(1)Database'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1908 values('MongoDB 2 Database'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1908 values('MySQL(3)Database'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1908 values('SQL Server(10)Database'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1908 values('MySQL 8 Database'); Query OK, 1 row affected (0.00 sec)显示所有记录从 ... 阅读更多
131 次查看
让我们首先创建一个表 -mysql> create table DemoTable1907 ( UserId int NOT NULL AUTO_INCREMENT, UserName varchar(20), UserAge int, UserCountryName varchar(20), PRIMARY KEY(UserId) )ENGINE=MyISAM, AUTO_INCREMENT=100; Query OK, 0 rows affected (0.00 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1907(UserName, UserAge, UserCountryName) values('Chris', 26, 'US'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1907(UserName, UserAge, UserCountryName) values('David', 38, 'UK'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1907(UserName, UserAge, UserCountryName) values('John', 28, 'AUS'); Query OK, 1 row affected (0.00 sec)显示所有记录从 ... 阅读更多
423 次查看
要更改日期的格式,请使用 DATE_FORMAT() 函数。 让我们先创建一个表 -mysql> create table DemoTable1906 ( DueTime datetime ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1906 values(now()); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1906 values(curdate()); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1906 values('2017-10-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1906 values('2015-01-12'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1906 values('2018-04-25'); Query OK, 1 row affected (0.00 ... 阅读更多
298 次浏览
要加快进程,可以使用索引。 让我们先创建一个表 -mysql> create table DemoTable1905 ( FirstName varchar(20), LastName varchar(20) , INDEX F_L_Name(FirstName, LastName) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1905 values('John', 'Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1905 values('John', 'Doe'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1905 values('Adam', 'Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1905 values('John', 'Doe'); Query OK, 1 row affected (0.00 sec) ... 阅读更多