美文网首页
MySQL基础操作

MySQL基础操作

作者: 小阿飞的小蝴蝶 | 来源:发表于2022-12-26 14:14 被阅读0次

打开MySQL
我的电脑 -> 管理 -> 计算机管理 -> 服务和应用程序 -> MySQL 打开

关闭MySQL
任务管理器 mysqld.exe 关闭进程

MySQL基础命令
(MySQL基础命令)

cmd 进入D:\mysql\mysql-8.0.25-winx64\bin目录
登录数据库
mysql -u root -p 密码

显示数据库列表
show databases;

显示库中的数据表
use seckill;
show tables;

显示表结构
describe goods;

查看表数据
select * from goods;

建库与删库:
create database 库名;
drop database 库名;

建表:
use 库名;
create table 表名(字段列表);
create table device (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
info VARCHAR(50) NOT NULL);
drop table 表名;

清空表中记录:
delete from 表名;
truncate table 表名;

update tbl_user set age = 30 where user_name = 'jay'

select * from user_tbl where age=26 and signin_date='2022-12-28';

insert into user_tbl value('xiaoafei',26,'18513687318','1311257372','2022-12-27');

create table user_tbl(user_name varchar(30),age int,phone_num varchar(11),password varchar(20),signin_date date);

delete from tbl_user where user_name = 'jay';

alter table tbl_user add email varchar(30);

alter table tbl_user drop email;

alter table tbl_user change age user_age int;

alter table tbl_user change user_age user_age tinyint(1) not null;

alter table tbl_user rename user_tbl;

drop table user_tbl;

alter table user_tbl modify id int first;

alter table user_tbl modify signin_date date alter email;

insert into user (name,age,phone,password,email) values ('tom',33,'15623656564','6464634343','15623656564@qq.com');

select * from user limit 0,5; 第一页 5条数据

select * from user limit 5,5; 第二页 5条数据

select * from user limit 10,5; 第三页 5条数据

分页查询公式 (page - 1) * pageSize , pageSize.

select * from user limit (page - 1) * pageSize , pageSize;

//外连接 分为三种 左连接 右连接 全外连接
select * from tbl_user left join tbl_address on tbl_user.id = tbl_address.user_id;

select * from tbl_user right join tbl_address on tbl_user.id = tbl_address.user_id;

select * from tbl_user full join tbl_address on tbl_user.id = tbl_address.user_id;

//内连接
select * from tbl_user join tbl_address on tbl_user.id = tbl_address.user_id where user_id = '10';

//交叉连接 没有where条件的交叉连接将产生连接表所涉及的笛卡尔积
select * from tbl_user cross join tbl_address;

group by 分组
having count(字段)>1 重复字段。

order by 排序
order by 字段 desc 降序
order by 字段 asc 升序
字段 & 1 取奇

相关文章

  • MySql数据库基础及IDE

    一、基础操作--sql语句 启动MySQL:service mysql start停止MySQL:service ...

  • 005——MySQL

    基础 配置phpmyadmin MySQL重启 PHP中操作MySQL的基本代码和流程 测试 循环MySQL 数据...

  • 5.1MySQL数据库基础考点

    全方位剖析 考点分析 MySQL数据类型延伸:MySQL的基础操作延伸:MySQL存储引擎延伸:MySQL存储机制...

  • MySql 基础操作命令和语法

    MySql 基础操作 个人复习留档,方便以后回顾 MySQL服务 连接数据库 下面所有操作都需要登录成功才能操作 ...

  • mysql操作基础

    mysql -u root -p 连接数据库

  • mysql基础操作

    主要单词: show:展示,显示 primary:主要的 modify:修改 alter:改变 change:改变...

  • MySQL基础操作

    1;连接数据库 查看数据的各种方式 MySQL -hlocalhost -uroot -p123456; show...

  • MySQL基础操作

    数据库基本操作 查看所有用户:SELECT user FROM mysql.user;新建新用户:CREATE U...

  • MySQL——基础操作

    数据库基本操作(内部基本操作) create table emp(id int not null auto_inc...

  • mysql基础操作

    一、mysql基础操作(centos5.5) 1.mysql表复制 create table t3 like t1...

网友评论

      本文标题:MySQL基础操作

      本文链接:https://www.haomeiwen.com/subject/bnrnqdtx.html