当前位置:网站首页>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'的员工信息
边栏推荐
猜你喜欢

C language - array

2022 Google CTF SEGFAULT LABYRINTH wp

Typical problems of subnet division and super network construction
![JS reverse -- ob confusion and accelerated music that poked the [hornet's nest]](/img/40/da56fe6468da64dd37d6b5b0082206.png)
JS reverse -- ob confusion and accelerated music that poked the [hornet's nest]

Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which

AcWing 361. 观光奶牛 题解(spfa求正环)

Go zero micro service practical series (IX. ultimate optimization of seckill performance)

Make Jar, Not War

百度飞将BMN时序动作定位框架 | 数据准备与训练指南 (下)

LeetCode:1175. Prime permutation
随机推荐
Add the applet "lazycodeloading": "requiredcomponents" in taro,
Spark TPCDS Data Gen
爬虫实战(六):爬笔趣阁小说
AcWing 1140. Shortest network (minimum spanning tree)
Machine learning: the difference between random gradient descent (SGD) and gradient descent (GD) and code implementation.
Transplant DAC chip mcp4725 to nuc980
云呐|工单管理软件,工单管理软件APP
2022 Google CTF SEGFAULT LABYRINTH wp
1123. 最深叶节点的最近公共祖先
Right mouse button customization
各种语言,软件,系统的国内镜像,收藏这一个仓库就够了: Thanks-Mirror
Receive user input, height BMI, BMI detection small business entry case
Gazebo的安装&与ROS的连接
7.6模拟赛总结
mysqlbackup 还原特定的表
Vocabulary in Data Book
Set up [redis in centos7.x]
shell脚本快速统计项目代码行数
MySQL script batch queries all tables containing specified field types in the database
[advanced C language] 8 written questions of pointer