当前位置:网站首页>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'的员工信息
边栏推荐
- 1123. 最深叶节点的最近公共祖先
- AcWing 346. 走廊泼水节 题解(推公式、最小生成树)
- Drag to change order
- curl 命令
- C语言实例_5
- Go zero micro service practical series (IX. ultimate optimization of seckill performance)
- AcWing 1142. 繁忙的都市 题解(最小生成树)
- Yunna | work order management measures, how to carry out work order management
- 454-百度面经1
- 1123. The nearest common ancestor of the deepest leaf node
猜你喜欢
Go zero micro service practical series (IX. ultimate optimization of seckill performance)
AcWing 345. Cattle station solution (nature and multiplication of Floyd)
Comparison of picture beds of free white whoring
云呐|工单管理软件,工单管理软件APP
对C语言数组的再认识
AcWing 345. 牛站 题解(floyd的性质、倍增)
Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which
454-百度面经1
微信公众号发送模板消息
Wood extraction in Halcon
随机推荐
Neon Optimization: performance optimization FAQ QA
AcWing 346. Solution to the problem of water splashing festival in the corridor (deduction formula, minimum spanning tree)
Using the entry level of DVA in taro3.*
Yunna - work order management system and process, work order management specification
Yunna | work order management software, work order management software app
1123. The nearest common ancestor of the deepest leaf node
Right mouse button customization
Share a general compilation method of so dynamic library
Google released a security update to fix 0 days that have been used in chrome
JS reverse -- ob confusion and accelerated music that poked the [hornet's nest]
AcWing 1140. Shortest network (minimum spanning tree)
从底层结构开始学习FPGA----FIFO IP的定制与测试
AcWing 345. Cattle station solution (nature and multiplication of Floyd)
2022 Google CTF SEGFAULT LABYRINTH wp
C语言实例_2
Send template message via wechat official account
长按按钮执行函数
【芯片方案设计】脉搏血氧仪
Neon Optimization: summary of performance optimization experience
C language instance_ four