create database or table – 业余语言练习

create database or table

MySQL [(none)]> create database mydb;
Query OK, 1 row affected (0.093 sec)

MySQL [(none)]> use mydb;
Database changed
MySQL [mydb]> create table employee;
ERROR 1113 (42000): A table must have at least 1 column
MySQL [mydb]> create table employee\
(name varchar(20) not null, number varchar(10),\
 age char(5), department varchar(50));
Query OK, 0 rows affected (0.094 sec)

MySQL [mydb]> desc employee;
+------------+-------------+------+-----+---------+-------+
| Field      | Type        | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| name       | varchar(20) | NO   |     | NULL    |       |
| number     | varchar(10) | YES  |     | NULL    |       |
| age        | char(5)     | YES  |     | NULL    |       |
| department | varchar(50) | YES  |     | NULL    |       |
+------------+-------------+------+-----+---------+-------+
4 rows in set (0.093 sec)
MySQL [mydb]> create table job
    -> (name varchar(20) not null,
    -> number varchar(10),
    -> age char(5),
    -> department varchar(50));
Query OK, 0 rows affected (0.088 sec)

MySQL [mydb]> 
Published
Categorized as mysql

Leave a comment

Your email address will not be published. Required fields are marked *