数据库知识
2020-03-12 本文已影响0人
郭千岁呗
SQL语言分为以下四类:
DDL语句 数据库定义语言: 定义数据库、表、视图、索引、存储过程 例如create drop alter
DML语句 数据库操纵语言: 关于数据的插入insert 更新update 删除delete
DQL语句 数据库查询语言:数据查询select
DCL语句 数据库控制语言:例如控制用户的访问权限:grant revoke
定义数据库时要区分大小写;唯一性;不能使用关键字 例如create select;不能单独使用数字和特殊符号如 -
定于数据表时,字段类型分为三种:
1.数值类型:整数类型:int ; 浮点数类型:float
2.字符串类型:枚举类型 enum 单选 ; 集合类型set 多选
3.时间和日期类型:年 year; 日期date ;时间time;时间和日期 DATETIME;
创建一个库并添加数据
create 库名;

查看库 show databases;

进入库 :use 库名;

创建表: create table 表名 (字段1名,类型,约束,字段n);

插入数据 insert into 表名 values (各字段对应数据);
查询 select * from 表名;
查看表结构 desc 表名;
