Mysql> drop database if exists Jianghu; Create a new database, if it exists, after deletion;
Query OK, 0 rows affected, 1 Warning (0.00 sec)
mysql> CREATE DATABASE Jianghu;
Query OK, 1 row Affected (0.00 sec)
mysql> show databases; Display database information;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MyDB |
| MySQL |
| Students |
| Test |
| TestDB |
+--------------------+
6 rows in Set (0.01 sec)
mysql> use Jianghu; Select a database;
Database changed
Create a table with ID as the primary key
Mysql> CREATE TABLE student (ID int (3) auto_increment NOT null primary key,
, name Char (TEN) is not NULL,
-Age Int (2) is not NULL,
Course varchar (40),
-Entertime date)
;
Query OK, 0 rows affected (0.05 sec)
Mysql> Show tables; display table information;
+-------------------+
| Tables_in_jianghu |
+-------------------+
| Student |
+-------------------+
1 row in Set (0.01 sec)
mysql> desc Student; Show Table Structure
+-----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+----------------+
| ID | Int (3) | NO | PRI | NULL | auto_increment |
| name | char (10) | NO | | NULL | |
| Age | Int (2) | NO | | NULL | |
| Course | varchar (40) | YES | | NULL | |
| Entertime | Date | YES | | NULL | |
+-----------+-------------+------+-----+---------+----------------+
5 rows in Set (0.00 sec)
Insert data to table:
mysql> INSERT into student (Id,name,age,course) VALUES (1, ' Linghu ', ' Dugujiujian ');
Query OK, 1 row Affected (0.00 sec)
Mysql> SELECT * from student;
+----+--------+-----+-------------+-----------+
| ID | name | Age | Course | Entertime |
+----+--------+-----+-------------+-----------+
| 1 | Linghu | 18 | Dugujiujian | NULL |
+----+--------+-----+-------------+-----------+
1 row in Set (0.00 sec)
MySQL Simple operation