一、数据保存到数据库软件的优点:1.可以使数据永久保存下来。2.数据管理非常方便。
二、SQL:SQL(Structured Query Language)数据化结构查询语言。是一种和数据库交互的语言,进行数据库的管理。管理数据库、管理表、管理数据。
三、语句,sql语句必须以分号结尾,所有符号都是英文半角状态下的。
四、数据库的基本操作。
查询所有数据库: show databases;
查询数据库的创建语句: show create database 库名
创建数据库:create database 库名; (创建的是默认编码集的数据库)
create database 库名 character set 编码集; (创建自定义编码集的数据库)
删除数据库: drop database 库名;
修改数据库: alter database 库名 character set 编码集。
五、表的基本操作。
进入表:use 库名;
查询所有表:show tables;
创建表:create table 表名(
字段名 字段类型,
字段名 字段类型,
字段名 字段类型
)
查看表结构:desc 表名;
修改表:
添加字段:alter table 表名 add column 字段名 字段类型;
删除字段:alter table 表名 drop column 字段名;
修改字段类型:alter table 表名 modify column 字段名 字段类型 ;
修改字段名:alter table 表名 change column 字段名;
修改表名称 :alter table 表名 rename to 表名;
删除表:drop table 表名;