创建数据库
MariaDB [(none)]> create database web;
Query OK, 1 row affected (0.00 sec)
使用数据库
MariaDB [(none)]> use web;
Database changed
创建表
MariaDB [web]> create table user(
-> id int primary key auto_increment, #将ID设置为主键并自动增加值
-> username varchar(20),
-> password char(32));
Query OK, 0 rows affected (0.02 sec)
查看表
MariaDB [web]> desc user;
+----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| username | varchar(20) | YES | | NULL | |
| password | char(32) | YES | | NULL | |
+----------+-------------+------+-----+---------+----------------+
3 rows in set (0.03 sec)
删除数据库 drop database web;
删除新表 drop table user;
PS:
-> intime timestamp default current_timestamp); #设置创建时间