mysql 基础使用教程

用户登录

mysql -uroot -p

以管理员账号和密码登陆,使用其他账户请把root修改为相应用户名

查看数据库

show databases;

创建数据库

create database school;

进入数据库

use school

查看数据库中的所有表

show tables;

创建表

create table Student(
  SNO char(7) primary key,
  SNAME varchar(20) not null,
  SDEPT varchar(20) default '计算机'
)comment='学生表';
设置SNO作为主键,SNAME的值不能为空,SDEPT的默认值是计算机,整张表的备注为学生表。

查看表结构

desc school.Student;

查看表格创建信息

show create table Student;

查看表数据

select * from Student;
select SNO,SNAME,SDEPT from Student;

插入数据

insert into Student values ('9513101','罗大力','教育数学');

删除数据

delect from Student;
delect from Student where SNAME='罗大力';

修改数据

update table Student set SDEPT='物联网' where SNAME='罗大力';


猜你喜欢

转载自blog.csdn.net/a912952381/article/details/80687820