当前位置:网站首页>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'的员工信息
边栏推荐
- 736. Lisp 语法解析 : DFS 模拟题
- 鼠标右键 自定义
- swiper组件中使用video导致全屏错位
- [advanced C language] 8 written questions of pointer
- JS reverse -- ob confusion and accelerated music that poked the [hornet's nest]
- What does security capability mean? What are the protection capabilities of different levels of ISO?
- C language - array
- 制作带照明的DIY焊接排烟器
- Body mass index program, entry to write dead applet project
- hdu 4661 Message Passing(木DP&组合数学)
猜你喜欢

ClickHouse字段分组聚合、按照任意时间段粒度查询SQL

一起看看matlab工具箱内部是如何实现BP神经网络的

微信公众号发送模板消息

mongodb查看表是否导入成功

今日问题-2022/7/4 lambda体中修改String引用类型变量

LeetCode:1175. Prime permutation

Js逆向——捅了【马蜂窝】的ob混淆与加速乐
![[signal and system]](/img/aa/a65d6da1d1d9410254ca7b775e24a6.png)
[signal and system]

Today's question -2022/7/4 modify string reference type variables in lambda body

Let's see how to realize BP neural network in Matlab toolbox
随机推荐
mysqlbackup 还原特定的表
AcWing 1142. 繁忙的都市 题解(最小生成树)
Metauniverse urban legend 02: metaphor of the number one player
从底层结构开始学习FPGA----FIFO IP的定制与测试
安全保护能力是什么意思?等保不同级别保护能力分别是怎样?
go-zero微服务实战系列(九、极致优化秒杀性能)
Appium automation test foundation uiautomatorviewer positioning tool
Google released a security update to fix 0 days that have been used in chrome
图片打水印 缩放 和一个输入流的转换
Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period
table表格设置圆角
分享一个通用的so动态库的编译方法
C language instance_ four
According to the analysis of the Internet industry in 2022, how to choose a suitable position?
JS reverse -- ob confusion and accelerated music that poked the [hornet's nest]
移植DAC芯片MCP4725驱动到NUC980
WCF基金会
今日问题-2022/7/4 lambda体中修改String引用类型变量
【信号与系统】
Gin introduction practice