启动:net start mysql80
停止:net stop mysql80
退出:exit quit \q
show databases;
use databese_name;
show tables;
describe table_name;
查看具体内容则需要用到查询语句
select * from table_name;
修改数据库、表
创建数据库
create database 数据库名称
删除数据库
drop database 数据库名称
建立一个表
create table table_name (colun_name column_type)
案例:
create table if not exists score(
score_id int not null auto_increment,
score_title varchar(10) not null,
score_name varchar(10) not null,
score_score float(3),
primary key (score_id)
) engine=innodb default charset=utf8;
- 如果你不想字段为 NULL 可以设置字段的属性为 NOT NULL, 在操作数据库时如果输入该字段的数据为NULL ,就会报错。
- AUTO_INCREMENT定义列为自增的属性,一般用于主键,数值会自动加1。
- PRIMARY KEY关键字用于定义列为主键。 您可以使用多列来定义主键,列间以逗号分隔。
- ENGINE 设置存储引擎,CHARSET 设置编码。
删除表
drop table table_name
插入数据
insert into table_name(field1,field2,...fieldN) values (value1,value2,...valueN)
案例:
mysql中
insert into test_score(score_title,score_name,score_score) values('高数','小明','98')
python中
sql="""insert into score(title,name,score)
values('高数','小明','98')"""
前后三个双引号是表示换行连续
删除数据