前端展示 后臺存儲數(shù)據(jù)
數(shù)據(jù)結(jié)構 算法
數(shù)據(jù)庫DB 數(shù)據(jù)庫管理系統(tǒng)DBMS 表 行 列 數(shù)據(jù)類型 SQL
Oracle SQL server MySQL DB2
非關系型數(shù)據(jù)庫:redis mongdb
用壓縮包安裝MySQL5.7---配置路徑到環(huán)境變量---新建MySQL配置文件my.ini---進入bin目錄下癣漆,以管理員權限運行mysqld -install----初始化數(shù)據(jù)文件mysqld --initialize-insecure --user=mysql ----- 再次啟動MySQL ----mysql -u root -p
-- 單行注釋
/* 多行注釋 */
mysql> show databases; --查看所有數(shù)據(jù)庫典徊,所有語句分號結(jié)尾
+--------------------+
| Database |
+--------------------+
| information_schema |
| bjpowernode |
| bzbh |
| customers |
| girls |
| logdb |
| myemployees |
| mysql |
| performance_schema |
| school |
| sys |
| test |
+--------------------+
12 rows in set (0.32 sec)
mysql> use school; --切換數(shù)據(jù)庫
Database changed
mysql> show tables; --查看數(shù)據(jù)庫中所有表
+------------------+
| Tables_in_school |
+------------------+
| major |
| result |
| student |
+------------------+
3 rows in set (0.00 sec)
mysql> desc student; --查看表的結(jié)構
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| studentno | varchar(10) | NO | PRI | NULL | |
| studentname | varchar(20) | NO | | NULL | |
| loginpwd | varchar(8) | NO | | NULL | |
| sex | char(1) | YES | | NULL | |
| majorid | int(11) | NO | | NULL | |
| phone | varchar(11) | YES | | NULL | |
| email | varchar(20) | YES | | NULL | |
| borndate | datetime | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
8 rows in set (0.03 sec)
創(chuàng)建數(shù)據(jù)庫 create database if not exists test;
刪除數(shù)據(jù)庫:drop database if exists test;
數(shù)據(jù)庫中的數(shù)據(jù)類型:
數(shù)值:tinyiny smallint int float decimal字符串形式的浮點數(shù)
字符串:char varchar
時間日期:date time datetime timestamp
null: 不要使用null參與運算然评,因為結(jié)果為null
unsigned 無符號整數(shù)功炮,聲明了該列不能為負數(shù)
zerofill 零填充
自增
非空
默認
id 主鍵
`version` 樂觀鎖
is_delete 偽刪除
gmt_create 創(chuàng)建時間
gmt_update 修改時間
創(chuàng)建表
create table if not exists `student` (
`id` int(4) not null auto_increment comment '注釋內(nèi)容',
`name` varchar(20) not null default '匿名' comment '姓名',
`pwd` varchar(20) not null default '123456' comment '密碼',
`sex` varchar(2) not null default '女' comment '性別',
`birthday` datetime default null comment '出生日期',
`address` varchar(100) default null comment '家庭住址',
`email` varchar(40) default null comment '郵箱',
primary key (`id`)
)engine=innodb default charset=utf8
show create database school;
show create table student;
修改表 alter table student add age int(10);
alter table student modify age varchar(10);
alter table student change age nian_ling(10);
alter table student drop age;
刪除表 drop table student;