找到 4379 篇文章 关于 MySQL
102 次浏览
让我们首先创建一个表 - mysql> create table DemoTable ( Title text ); Query OK, 0 rows affected (0.39 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('Introduction to MySQL'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Introduction to Java'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('Introduction to SQL'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Introduction to Python'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Introduction to SQL'); Query OK, 1 row affected (0.09 sec) ... 阅读更多
172 次浏览
要显示,请使用 DESC 命令或 information_schema.columns。让我们首先创建一个表并设置选项 - mysql> create table DemoTable ( Color SET('RED', 'GREEN', 'BLUE', 'YELLOW') ); Query OK, 0 rows affected (0.47 sec) 案例 1 以下是使用 DESC 命令获取 SET 可用选项列表的查询 - mysql> desc DemoTable; 这将产生以下输出 - +-------+------------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | ... 阅读更多
848 次浏览
要插入随机数,请使用 MySQL 中的 RAND() 函数。让我们首先创建一个表 - mysql> create table DemoTable ( Value int ); Query OK, 0 rows affected (0.46 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.08 sec) 使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable; 这将产生以下输出 - +-------+ | Value | +-------+ | ... 阅读更多
100 次浏览
要以所需方式删除记录,语法如下 - delete from yourTableName where yourTableName.yourColumnName=yourValue; 让我们首先创建一个表 - mysql> create table DemoTable ( StudentName varchar(100), StudentAge int ); Query OK, 0 rows affected (0.81 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('Chris', 21); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Robert', 20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('David', 22); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Mike', 24); Query OK, 1 row ... 阅读更多
154 次浏览
让我们首先创建一个表 - mysql> create table DemoTable( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(100), AdmissionDate date ); Query OK, 0 rows affected (0.42 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable(Name, AdmissionDate) values('Chris', '2019-11-21'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(Name, AdmissionDate) values('Mike', '2019-03-11'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Name, AdmissionDate) values('Sam', '2018-04-01'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(Name, AdmissionDate) values('Carol', '2019-05-01'); Query OK, 1 row affected (0.40 sec) 显示所有记录 ... 阅读更多
685 次浏览
让我们首先创建一个表 - mysql> create table DemoTable1 ( Name varchar(100), Gender ENUM('MALE', 'FEMALE') ); Query OK, 0 rows affected (0.50 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1 values('Chris', 'Male'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1 values('Emma', 'Female'); Query OK, 1 row affected (0.19 sec) 使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable1; 这将产生以下输出 - +-------+--------+ | Name | Gender | +-------+--------+ | Chris | MALE | | Emma | FEMALE | +-------+--------+ 2 rows in set ... 阅读更多
268 次浏览
让我们首先创建一个表 - mysql> create table DemoTable ( Name varchar(100), Age int ); Query OK, 0 rows affected (0.46 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('Chris', 23); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('David', 55); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Bob', 53); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('Mike', 54); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values('Sam', 55); Query OK, 1 row affected (0.18 sec) 显示所有记录 ... 阅读更多
532 次浏览
让我们首先创建一个表 - mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100) ); Query OK, 0 rows affected (0.46 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable(FirstName) values('Chris'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(FirstName) values('Robert'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(FirstName) values('Robert'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(FirstName) values('John'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(FirstName) values('John'); Query OK, 1 row affected (0.11 sec) mysql> insert ... 阅读更多
100 次浏览
让我们首先创建一个表 - mysql> create table DemoTable ( FirstName varchar(100), LastName varchar(100) ); Query OK, 0 rows affected (0.76 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('Chris', 'Brown'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Adam', 'Smith'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Carol', 'Taylor'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('David', 'Miller'); Query OK, 1 row affected (0.12 sec) 使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable; 这将产生 ... 阅读更多
1K+ 次浏览
要更新一个为 null 的字段,请将 IS NULL 属性与 UPDATE 命令一起使用。让我们首先创建一个表 - mysql> create table DemoTable ( StudentScore int ); Query OK, 0 rows affected (0.47 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(89); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(56); ... 阅读更多