title: 05-数据库与表单
order: 5
icon: lightbulb
在Mariadb数据库系统中, 一个数据库可以存放多个数据表,数据表单是数据库最重要的核心内容。表 18.2讲述了一些常用的数据库命令及其对应的作用
1、创建一个名为zxw的数据库,使用命令create database
MariaDB [(none)]> create database zxw;
2、查询数据库,看是否创建成功
MariaDB [(none)]> show databases;
3、切换到新建的zxw数据库中,并创建表单ceshi,分别定义3个字段,其中长度为15个字符的字符型 字段name用来存放图书名称,整型字段price和pages分别存放图书的价格和页数。
MariaDB [(none)]> use zxw;
MariaDB [zxw]> create table ceshi (name char(15),price int,pages int);
4、查询新建的表字段,使用命令describe,命令格式: describe【表名称】
MariaDB [zxw]> describe ceshi;
5、删除数据,使用命令 drop ,格式: drop database if exists 【数据库名称】
MariaDB [(none)]> drop database if exists zxw;
6、再次查询数据库
MariaDB [(none)]> show databases;
评论区