字段去重查询

select distinct style from music

批量修改某字段

update music set style = "ost"  where style like "%影视剧%"

先查询,再添加或修改数据字段

select * from music where language  is null

update music set language = "外国" where language is null

mysql的sql实现

mysql> alter table 国产 rename to guochan;
习惯上函数用大写,但小写也可以
mysql> select now();
select ascii('f');
返回字符串str的第一个字符的ASCII值(str是空串时返回0),总是加单引号。
select CHAR(77,121,83,86,77);
增删改查语句

MariaDB [EMP]> insert into Employees values (100,18,'aa','bb');
Query OK, 1 row affected (0.02 sec) MariaDB [EMP]> insert into Employees values (101,19,'a2','b2');
Query OK, 1 row affected (0.02 sec) MariaDB [EMP]> insert into Employees values (101,19,'zara','b3');
Query OK, 1 row affected (0.01 sec) MariaDB [EMP]> insert into Employees values (105,30,'a4','b4');
Query OK, 1 row affected (0.01 sec) MariaDB [EMP]> select * from Employees;
+-----+-----+-------+------+
| id | age | first | last |
+-----+-----+-------+------+
| 100 | 18 | aa | bb |
| 101 | 19 | a2 | b2 |
| 101 | 19 | zara | b3 |
| 105 | 30 | a4 | b4 |
+-----+-----+-------+------+
4 rows in set (0.00 sec) MariaDB [EMP]> UPDATE Employees SET id=102 WHERE first='zara';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [EMP]> select * from Employees;
+-----+-----+-------+------+
| id | age | first | last |
+-----+-----+-------+------+
| 100 | 18 | aa | bb |
| 101 | 19 | a2 | b2 |
| 102 | 19 | zara | b3 |
| 105 | 30 | a4 | b4 |
+-----+-----+-------+------+
4 rows in set (0.00 sec) MariaDB [EMP]> delete from Employees where id=105;
MariaDB [EMP]> select * from Employees;
+-----+-----+-------+------+
| id | age | first | last |
+-----+-----+-------+------+
| 100 | 18 | aa | bb |
| 101 | 19 | a2 | b2 |
| 102 | 19 | zara | b3 |
+-----+-----+-------+------+
3 rows in set (0.00 sec) MariaDB [EMP]> insert into Employees values(108,29,'wu','ma');
Query OK, 1 row affected (0.03 sec) MariaDB [EMP]> insert into Employees values(109,26,'wang','wei');
Query OK, 1 row affected (0.02 sec) MariaDB [EMP]> select * from Employees;
+-----+-----+-------+------+
| id | age | first | last |
+-----+-----+-------+------+
| 100 | 18 | aa | bb |
| 101 | 19 | a2 | b2 |
| 102 | 19 | zara | b3 |
| 108 | 29 | wu | ma |
| 109 | 26 | wang | wei |
+-----+-----+-------+------+
5 rows in set (0.00 sec) show variables like '%FOREIGN%';
SET FOREIGN_KEY_CHECKS=0; delete from geographical_position where type = 1
select distinct type from geographical_position mysql> create user 'ab'@'localhost' identified by 'weeee';
mysql> select user,host,password from mysql.user; INSERT(str,pos,len,newstr)
instr mysql> select instr('contents','t');
+-----------------------+
| instr('contents','t') |
+-----------------------+
|                     4 |
+-----------------------+
1 row in set (0.00 sec) mysqldump -u root -d -R --add-drop-table spa >spa.sql
sed -i '1i\use spa;' spa.sql
sed -i '1i\create database spa;' spa.sql
sed -i '1i\drop database if exists spa;' spa.sql
mysqldump -u root   --add-drop-table spa action_buttons>>spa.sql
mysqldump -u root   --add-drop-table spa menu>>spa.sql
mysqldump -u root   --add-drop-table --extended-insert=false spa tb_sequence>>spa.sql
mysqldump -u root   --add-drop-table spa role --where="id=20" >>spa.sql
mysqldump -u root   --add-drop-table spa role_button_relation --where="role_id=20" >>spa.sql
mysqldump -u root   --add-drop-table spa user_role_relation --where="role_id=20" >>spa.sql
mysqldump -u root   --add-drop-table spa system_user --where="username='admin'" >>spa.sql -d, --no-data       No row information.
-R, --routines      Dump stored routines (functions and procedures). select * from tb_sequence limit 0,1
limit是mysql的语法
select * from table limit m,n
其中m是指记录开始的index,从0开始,表示第一条记录
n是指从第m+1条开始,取n条。
select * from tablename limit 2,4
即取出第3条至第6条,4条记录 [root@db mysql]# mysqlshow
[root@db mysql]# mysql -e 'select user,password,host from mysql.user'
mysql> delete from user where user = '';    删除匿名用户
mysql> drop user ''@localhost ;

mysql-sql语言参考的更多相关文章

  1. MySQL sql语言的笔记

    3 MySQL数据库 3.1 mysql数据存储结构 先数据库,再表,再有数据 4 数据库管理 4.1 查询所有数据库 mysql> show databases; +------------- ...

  2. sql语言参考

    set operators UNION, UNION ALL, INTERSECT, and MINUS这三个操作符优先级相同,从左至右,除非有括号 单库单表操作,单库多表操作,多库多表操作(用到db ...

  3. mysql数据库基本操作sql语言

    mysql的启动与关闭 启动 /etc/init.d/mysql start 多实例使用自建脚本启动 2种关闭数据库方法 mysqladmin -uroot -p密码 shutdown #优雅关闭/e ...

  4. [SQL]SQL语言入门级教材_SQL语法参考手册(三)

    SQL 语法参考手册 DB2 提供了关连式资料库的查询语言 SQL (Structured Query Language),是一种非常口语化.既易学又易懂的语法. 此语言几乎是每个资料库系统都必须提供 ...

  5. 自学SQL语言的例子(使用MySQL实现)

    SQL语言作为一种数据库管理的标准语言有着极为广泛的应用场景,菜鸟入门选用的数据库软件是轻量级的免费(这个极为重要)的MySQL,下载链接如下:http://www.mysql.com/downloa ...

  6. MySQL的sql语言分类DML、DQL、DDL、DCL、

    MySQL的sql语言分类DML.DQL.DDL.DCL. SQL语言一共分为4大类:数据定义语言DDL,数据操纵语言DML,数据查询语言DQL,数据控制语言DCL 1.数据定义语言DDL(Data ...

  7. MySQL从删库到跑路(三)——SQL语言

    作者:天山老妖S 链接:http://blog.51cto.com/9291927 一.SQL语言简介 1.SQL语言简介 SQL是结构化查询语言(Structured Query Language) ...

  8. 【MySQL笔记】SQL语言四大类语言

     SQL语言共分为四大类:数据查询语言DQL,数据操纵语言DML,数据定义语言DDL,数据控制语言DCL.   1. 数据查询语言DQL 数据查询语言DQL基本结构是由SELECT子句,FROM子句, ...

  9. MySQL入门——MySQL数据库和SQL语言

    MySQL入门——MySQL数据库和SQL语言 摘要:本文主要了解了MySQL关系型数据库和SQL语言的基本知识. MySQL数据库 简介 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB ...

  10. Python进阶----数据库的基础,关系型数据库与非关系型数据库(No SQL:not only sql),mysql数据库语言基础(增删改查,权限设定)

    day37 一丶Python进阶----数据库的基础,mysql数据库语言基础(增删改查,权限设定) 什么是数据库:    简称:DataBase ---->DB    数据库即存放数据的仓库, ...

随机推荐

  1. 5.2 C++重载操作符的优先级

    参考:http://www.weixueyuan.net/view/6380.html 总结: 重载操作符不能改变操作符的优先级和语法特性. 重载操作符不能改变操作符的优先级和语法特性.例如上一节复数 ...

  2. SQL-2 查找入职员工时间排名倒数第三的员工所有信息

    题目描述 查找入职员工时间排名倒数第三的员工所有信息CREATE TABLE `employees` (`emp_no` int(11) NOT NULL,`birth_date` date NOT ...

  3. centos下mysql数据迁移方法

    第一种: 原始数据库不需要重新安装: 默认mysql会安装在/var/lib/mysql这里,若将数据迁移到/data/mysql目录下,步骤如下: 1.停止mysql服务 2.#cp /var/li ...

  4. Python 连接 redis 模块

    redis 模块使用可以分类为: 连接方式 连接池 操作 String操作 Hash操作 List操作 Set操作 Sort Set操作 管道 发布订阅 (1)操作模式 redis提供两个类Redis ...

  5. 关于selenium实现滑块验证

    关于selenium实现滑块验证 python2.7+selenium2实现淘宝滑块自动认证参考链接:https://blog.csdn.net/ldg513783697/article/detail ...

  6. 2019-03-04-day003-运算符

    01 上周内容回顾 格式化输出: msg = '我的名字%s,我的年龄%s' % ('太白',18) 单纯的表示% msg = '我的名字%s,我的年龄%s,学习进度3%%' % ('太白',18) ...

  7. Spring Boot 揭秘与实战(六) 消息队列篇 - RabbitMQ

    文章目录 1. 什么是 RabitMQ 2. Spring Boot 整合 RabbitMQ 3. 实战演练4. 源代码 3.1. 一个简单的实战开始 3.1.1. Configuration 3.1 ...

  8. i.MX6 设备树 GPIO 默认值

    /********************************************************************** * i.MX6 设备树 GPIO 默认值 * 说明: * ...

  9. SLES 12 SP2 安装src.rpm软件包

      系统型号: SUSE Enterprise  mv systemd-228-117.12.src.rpm   systemd     cd systemd 执行下面的命令解压:     rpm2c ...

  10. Codeforces 766C:Mahmoud and a Message(DP)

    题目链接:http://codeforces.com/problemset/problem/766/C 题意 有一个长度为n的字符串,第二行有26个数字,位置1~26对应为a~z的字母,数值表示该字母 ...