麒麟mysql常用命令


由提供 2024-11-12 34

查询数据库

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)

创建数据库

mysql> create database kylin;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| kylin |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)

切换数据库

mysql> use kylin;

Database changed

查询数据表

mysql> show tables;
Empty set (0.00 sec)

创建数据表

mysql> Create table student(Sid int primary key,Sname varchar(20) not null,Sex char(1),Brithdate date );
Query OK, 0 rows affected (0.06 sec)
mysql> show tables;
+-----------------+
| Tables_in_kylin |
+-----------------+
| student |
+-----------------+
1 row in set (0.00 sec)

查询数据表信息

mysql> select * from student;
Empty set (0.00 sec)

向表中插入数据

mysql> insert into student(Sid,Sname,Sex,Brithdate) values(1,'youth',1,'1999-4-15');
Query OK, 1 row affected (0.00 sec)
mysql> select * from student;
+-----+-------+------+------------+
| Sid | Sname | Sex | Brithdate |
+-----+-------+------+------------+
| 1 | youth | 1 | 1999-04-15 |
+-----+-------+------+------------+
1 row in set (0.00 sec)

删除数据表

mysql> show tables;
+-----------------+
| Tables_in_kylin |
+-----------------+
| student |
+-----------------+
1 row in set (0.00 sec)
mysql> drop table student;
Query OK, 0 rows affected (0.01 sec)
mysql> show tables;
Empty set (0.00 sec)

删除数据库

mysql> drop database kylin;
Query OK, 0 rows affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)

添加我为好友,拉您入交流群!

请使用微信扫一扫!