HeidiSQL中一些简单mysql语句的含义(一)

一、创建数据库

#创建一个数据库,这个是数据库的名字叫java62

create database java62;

#删除数据库java62

drop database java62;

#查看当前mysql里的所有数据库

show databases;

#创建student表,varchar括号里的是字符串的长度

create table student(no int ,name varchar(10),age int);

#查看当前数据库里有哪些表

show tables;

#删除student表

drop table student;

二、增删改查

#向student 表中插入数据

insert into student (no,name,age) values (1001,'张三',20);

#插入两条数据

insert into student (no,name,age) values(1002,'李四',21),(1003,'王五',22);

注:如果不想某个字段重复,可以给它设置主键

#当我要给表中每个字段都写入数据的时候,可以不写字段名

#如果给部分字段赋值,则必须写字段名

insert into student values (1004,'测试',20);

#删除表中所有数据

delete from student;

#在student表中删除no=1004的数据

delete from student where no=1004;

#把所有数据进行修改

update student set age=23 ;

#把 no=1003的一条数据中age改为23

update student set age=23 where no=1003;

#年龄加1

update student set age=age+1 where no=1003;

#把no=1003中name改为测试2,age改为20

update student set name='测试2',age=20 where no=1003;

#查询表中所有数据

select * from student;

#查询name的所有数据

select name from student;

#查询name和age

select name,.age from student;

#查询张三的所有数据

select * from student where name='张三';

#查询age>20的数据

select * from student where age>20;

#查询 name='张三' 或者age=21的数据

select * from student where name='张三' or age=21;

#查询 name='张三' 并且age=21的数据

select * from student where name='张三' and age=21;

相关推荐
Yushan Bai3 小时前
ORACLE RAC环境REDO日志量突然增加的分析
数据库·oracle
躺着听Jay3 小时前
Oracle-相关笔记
数据库·笔记·oracle
瀚高PG实验室3 小时前
连接指定数据库时提示not currently accepting connections
运维·数据库
运维成长记4 小时前
mysql数据库-中间件MyCat
数据库·mysql·中间件
尘客.4 小时前
DataX从Mysql导数据到Hive分区表案例
数据库·hive·mysql
TiDB 社区干货传送门5 小时前
从开发者角度看数据库架构进化史:JDBC - 中间件 - TiDB
数据库·oracle·中间件·tidb·数据库架构
虾球xz5 小时前
游戏引擎学习第280天:精简化的流式实体sim
数据库·c++·学习·游戏引擎
uwvwko6 小时前
BUUCTF——web刷题第一页题解
android·前端·数据库·php·web·ctf
扶尔魔ocy6 小时前
【Linux C/C++开发】轻量级关系型数据库SQLite开发(包含性能测试代码)
linux·数据库·c++·sqlite
旋风菠萝6 小时前
项目复习(1)
java·数据库·八股·八股文·复习·项目、