当前位置: 移动技术网 > IT编程>数据库>Mysql > MySQL必知必会 -- 使用MySQL

MySQL必知必会 -- 使用MySQL

2020年07月30日  | 移动技术网IT编程  | 我要评论
MariaDB [mysql]> create database test;/创建数据库Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> show databases;、查看数据库+--------------------+| Database |+--------------------+| information_schema || mysql || performa
MariaDB [mysql]> create database test;		/创建数据库
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;	、查看数据库
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [mysql]> use test;	/切换位置
Database changed
MariaDB [test]> create table linux (user varchar(30) not null,passwd varchar(20) not null,sex varchar(4) not null);
Query OK, 0 rows affected (0.01 sec)

MariaDB [test]> show table;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
MariaDB [test]> 
MariaDB [test]> show tables;
+----------------+
| Tables_in_test |
+----------------+
| linux          |
+----------------+
1 row in set (0.00 sec)

\MariaDB [test]> desc linux;		、查看表结构
+--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| user   | varchar(30) | NO   |     | NULL    |       |
| passwd | varchar(20) | NO   |     | NULL    |       |
| sex    | varchar(4)  | NO   |     | NULL    |       |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

MariaDB [test]> show columns from linux;		/作用和desc 相同
+--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| user   | varchar(30) | NO   |     | NULL    |       |
| passwd | varchar(20) | NO   |     | NULL    |       |
| sex    | varchar(4)  | NO   |     | NULL    |       |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

MariaDB [(none)]> SHOW CREATE DATABASE test;
+----------+-----------------------------------------------------------------+
| Database | Create Database                                                 |
+----------+-----------------------------------------------------------------+
| test     | CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+----------+-----------------------------------------------------------------+
1 row in set (0.01 sec)

MariaDB [test]> show create table linux;	分别用来显示创建特定数据库或表的MySQL语句;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                              |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| linux | CREATE TABLE `linux` (
  `user` varchar(30) NOT NULL,
  `passwd` varchar(20) NOT NULL,
  `sex` varchar(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+

SHOW STATUS,用于显示广泛的服务器状态信息;
SHOW GRANTS,用来显示授予用户(所有用户或特定用户)的安全权限;
SHOW ERRORS和SHOW WARNINGS,用来显示服务器错误或警告消息。
MariaDB [test]> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [test]> show ERRORS;
Empty set (0.01 sec)

MariaDB [test]> show WARNING;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WARNING' at line 1
MariaDB [test]> show WARNINGS;
+-------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                                                                     |
+-------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WARNING' at line 1 |
+-------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

本文地址:https://blog.csdn.net/thermal_life/article/details/107636106

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网