找到 4379 篇文章 关于 MySQL
2K+ 阅读量
让我们首先创建一个表 - mysql> create table DemoTable -> ( -> EmailAddress varchar(20), -> Score int -> ); Query OK, 0 rows affected (1.05 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('[email protected]', 67); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('[email protected]', 57); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('[email protected]', 98); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable;这将产生以下输出 -+------------------+-------+ | EmailAddress ... 阅读更多
214 阅读量
要删除尾随空格,请在 MySQL 中使用 RTRIM()。让我们首先创建一个表 - mysql> create table DemoTable -> ( -> FirstName varchar(50) -> ); Query OK, 0 rows affected (1.38 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('John '); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Chris '); Query OK, 1 row affected (0.51 sec) mysql> insert into DemoTable values(' David '); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Mike'); Query OK, 1 row affected (0.17 sec)显示表中的所有记录 ... 阅读更多
389 阅读量
让我们首先创建一个表 - mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.60 sec)使用 insert 命令在表中插入一些记录:使用 insert 命令在表中插入一些记录: mysql> insert into DemoTable values(100, 'Bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(101, 'Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(102, 'David'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(103, 'Sam'); Query OK, 1 row affected (0.08 sec) mysql> ... 阅读更多
214 阅读量
要更新 MySQL 表引擎,请遵循以下语法 - 语法 alter table yourTableName ENGINE=InnoDB;让我们首先创建一个表 - mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> StudentAge int, -> StudentCountryName varchar(20) -> )ENGINE=MyISAM, AUTO_INCREMENT=101; Query OK, 0 rows affected (0.18 sec)让我们检查表的描述 - mysql> show create table DemoTable;这将产生以下输出 -+---------------+-----------------------------------------------------------------------------------------+ | Table | Create Table ... 阅读更多
429 阅读量
为此,请使用 ORDER BY 子句。让我们首先创建一个表 - mysql> create table DemoTable -> ( -> StudentCode varchar(20) -> ); Query OK, 0 rows affected (0.57 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('101J'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('100A'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('100B'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('101S'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('103M'); Query OK, 1 row affected (0.15 ... 阅读更多
227 阅读量
为此,请使用 MAX() 以及 GROUP BY 子句。让我们首先创建一个表 - mysql> create table DemoTable -> ( -> StudentEmailId varchar(20), -> Marks1 int, -> Marks2 int -> ); Query OK, 0 rows affected (0.90 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('[email protected]', 45, 32); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values('[email protected]', 32, 45); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable values('[email protected]', 32, 45); Query OK, 1 row affected (1.64 sec) mysql> insert into DemoTable values('[email protected]', 45, 32); ... 阅读更多
164 阅读量
为此,请使用 GROUP BY 子句以及 MAX()。让我们首先创建一个表 - mysql> create table DemoTable -> ( -> CountryName varchar(20), -> Population int -> ); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('US', 560); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('UK', 10090); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('UK', 8794); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('US', 1090); Query OK, 1 row affected (0.21 sec)显示 ... 阅读更多
112 阅读量
是的,因为这是一个全局权限。让我们首先创建一个用户 - mysql> CREATE USER 'Jace'@'localhost' IDENTIFIED BY 'Jace123'; Query OK, 0 rows affected (0.67 sec)以下是使用 *.* 授予全局权限的查询:mysql> GRANT SELECT ON *.* TO 'Jace'@'localhost'; Query OK, 0 rows affected (0.58 sec)现在您可以显示用户的所有授权 - mysql> show grants for 'Jace'@'localhost';这将产生以下输出 -+-------------------------------------------+ | Grants for Jace@localhost | +-------------------------------------------+ | GRANT SELECT ON *.* TO `Jace`@`localhost` | +-------------------------------------------+ 1 row in set (0.14 sec)
86 阅读量
为此,您可以使用 ORDER BY DATE()。让我们首先创建一个表。这里,我们有一个类型为 DATE 的列,另一个类型为 ENUM - mysql> create table DemoTable -> ( -> JoiningDate date, -> Status ENUM('Good', 'Excellent', 'Bad') -> ); Query OK, 0 rows affected (0.58 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('2019-01-21', 'Excellent'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Status) values('Bad'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Status) values('Good'); Query OK, 1 row affected (0.13 sec)显示所有 ... 阅读更多
121 次查看
要进行排序,请使用 ORDER BY SUBSTRING()。让我们先创建一个表 -mysql> create table DemoTable -> ( -> Value varchar(40) -> ); Query OK, 0 rows affected (0.59 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('2321/78/54-6') -> ; Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2321/78/54-8'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('2321/78/54-5'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('2321/78/54-9'); Query OK, 1 row affected (0.21 sec)使用 select 语句显示表中的所有记录 ... 阅读更多