MySQL必知必会 -- 使用MySQL
程序员文章站
2024-01-17 13:29:40
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
上一篇: 关于ajax的多次请求问题