当前位置:网站首页>MySQL最基本的SELECT(查询)语句
MySQL最基本的SELECT(查询)语句
2022-07-06 18:09:00 【胡阳阳Y】
1.基本语句
(1)查看所有的数据库
show databases;
(2)创建自己的数据库
create database 数据库名
(3)使用自己的数据库
use 数据库名
(4)查看某个库所有的表格
show tables from 数据库名
(5)创建新的表格
create table 表名称( 字段名 数据类型,
字段名 数据类型 );
说明:如果是最后一个字段,后面就用加逗号,因为逗号的作用是分割每个字段。
(6)查看一个表的数据
select * from 数据库表名称;
(7)添加一条记录
insert into 表名称 values(值列表);
(8)查看表的创建信息
show tables;
(9)查看数据库的创建信息
show create database 数据库名\G
(10)删除表格
drop table 表名称;
(11)删除数据库
drop database 数据库名
(12)导入现有的数据表,表的数据
一.source 文件的全路径名
说明:只能在命令提示符使用
二.基于具体的图形化界面的工具可以导入数据
说明:我使用的是 SQLyog,Windows系统是不区分大小写的
但是SQLyog中关键字函数都是大写,所以后面的语句都会使用大写
2.最基本的SELECT语句
(1)SELECT 字段1,字段2,.....FROM 表名;
dual: 伪(假)表 *:表中的所有的字段(或列)
(2)列的全名
as:全称(alias(别名)),可以省略
列的别名可以使用一对" "引起来,不要使用' '
(3)去除重复行
SELECT DISTINCT 字段 FROM 表名;
(4)空值参与运算
空值:null
null不等同于0,' ','null'
空值参与运算:结果一定也为空
实际问题的解决方案:引入IFNULL
(5)着重号
SELECT * EROM 'order';//与关键字重名
(6)查询常数
列如:SELECT 'huyangyang',123,emplovee_id,last_name
FROM employees;
(7)显示表结构
DESCRIBE 表名;
显示了表中字段的详细信息
或DESC
(8)过滤数据
SELECT * FROM 表名 WHERE 字段 = 'huyangyang';
查询字段为'huyangyang'的员工信息
边栏推荐
- Set WordPress pseudo static connection (no pagoda)
- 黑马笔记---创建不可变集合与Stream流
- 数据手册中的词汇
- mysqlbackup 还原特定的表
- 增加 pdf 标题浮窗
- 子网划分、构造超网 典型题
- Add the applet "lazycodeloading": "requiredcomponents" in taro,
- AI 从代码中自动生成注释文档
- AcWing 1140. Shortest network (minimum spanning tree)
- Let's see how to realize BP neural network in Matlab toolbox
猜你喜欢

Make Jar, Not War

修改px4飞控的系统时间
![[signal and system]](/img/aa/a65d6da1d1d9410254ca7b775e24a6.png)
[signal and system]

Set WordPress pseudo static connection (no pagoda)

设置Wordpress伪静态连接(无宝塔)

Yunna | work order management measures, how to carry out work order management

Installation of gazebo & connection with ROS

Byte P7 professional level explanation: common tools and test methods for interface testing, Freeman

【C语言进阶篇】指针的8道笔试题

制作带照明的DIY焊接排烟器
随机推荐
shell脚本快速统计项目代码行数
云呐|工单管理办法,如何开展工单管理
Send template message via wechat official account
Byte P7 professional level explanation: common tools and test methods for interface testing, Freeman
2022 Google CTF SEGFAULT LABYRINTH wp
MySQL script batch queries all tables containing specified field types in the database
微信公众号发送模板消息
POJ 3177 Redundant Paths POJ 3352 Road Construction(双连接)
Drag to change order
7.6 simulation summary
Set up [redis in centos7.x]
Amway wave C2 tools
免费白嫖的图床对比
mongodb查看表是否导入成功
C language instance_ two
LeetCode:1175. Prime permutation
Spark TPCDS Data Gen
Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period
交叉验证如何防止过拟合
Start from the bottom structure to learn the customization and testing of fpga---- FIFO IP