Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. --显示所有的数据库 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.09 sec) --创建一个数据库test2 mysql> create database test2; Query OK, 1 row affected (0.00 sec) --使用数据库test2 mysql> use test2; Database changed --显示test2中的所有表 mysql> show tables; Empty set (0.00 sec) --创建一个mytable表 mysql> create table mytable (name varchar(20), sex char(1), -> birth date, birthaddr varchar(20)); Query OK, 0 rows affected (0.14 sec) --显示数据库中的所有表 mysql> show tables; +-----------------+ | Tables_in_test2 | +-----------------+ | mytable | +-----------------+ 1 row in set (0.02 sec) --显示表结构 mysql> describe mytable; +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | name | varchar(20) | YES | | NULL | | | sex | char(1) | YES | | NULL | | | birth | date | YES | | NULL | | | birthaddr | varchar(20) | YES | | NULL | | +-----------+-------------+------+-----+---------+-------+ 4 rows in set (0.07 sec) --查询表的所有字段 mysql> select * from mytable; Empty set (0.00 sec) --向表中插入一条记录 mysql> insert into mytable -> values( -> 'abc','f','1988-07-07','chian'); Query OK, 1 row affected (0.08 sec) --查看表的记录 mysql> select * from mytable; +------+------+------------+-----------+ | name | sex | birth | birthaddr | +------+------+------------+-----------+ | abc | f | 1988-07-07 | chian | +------+------+------------+-----------+ 1 row in set (0.00 sec)
mysql数据库创建,表创建,插入数据
最新推荐文章于 2024-05-20 07:27:45 发布