sql语言参考
字段去重查询
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 ;
sql语言参考的更多相关文章
- [SQL]SQL语言入门级教材_SQL语法参考手册(三)
SQL 语法参考手册 DB2 提供了关连式资料库的查询语言 SQL (Structured Query Language),是一种非常口语化.既易学又易懂的语法. 此语言几乎是每个资料库系统都必须提供 ...
- atitit.java解析sql语言解析器解释器的实现
atitit.java解析sql语言解析器解释器的实现 1. 解析sql的本质:实现一个4gl dsl编程语言的编译器 1 2. 解析sql的主要的流程,词法分析,而后进行语法分析,语义分析,构建sq ...
- [SQL]SQL语言入门级教材_跟我学SQL(六)
跟我学SQL:(一)数据查询 且不说你是否正在从事编程方面的工作或者不打算学习SQL,可事实上几乎每一位开发者最终都会遭遇它.你多半还用不着负责创建和维持某个,但你怎么着也该知道以下的一些有关的SQL ...
- [SQL]SQL语言入门级教材_SQL数据操作基础(二)
SQL数据操作基础(初级) netnova 于 -- :: 加贴在 数据库探讨: 为了建立交互站点,你需要使用数据库来存储来自访问者的信息.例如,你要建立一个职业介绍服务的站点,你就需要存储诸如个人简 ...
- Impala SQL 语言元素(翻译)[转载]
原 Impala SQL 语言元素(翻译) 本文来源于http://my.oschina.net/weiqingbin/blog/189413#OSC_h2_2 摘要 http://www.cloud ...
- Oracle学习笔记之四,SQL语言入门
1. SQL语言概述 1.1 SQL语言特点 集合性,SQL可以的高层的数据结构上进行工作,工作时不是单条地处理记录,而对数据进行成组的处理. 统一性,操作任务主要包括:查询数据:插入.修改和删除数据 ...
- Impala SQL 语言元素(翻译)
摘要: http://www.cloudera.com/content/cloudera-content/cloudera-docs/Impala/latest/Installing-and-Usin ...
- 学习笔记:oracle学习三:SQL语言基础之sql语言简介、用户模式
目录 1.sql语言简介 1.1 sql语言特点 1.2 sql语言分类 1.3 sql语言的编写规则 2.用户模式 2.1 模式与模式对象 2.2 实例模式scott 本系列是作为学习笔记,用于记录 ...
- mysql数据库基本操作sql语言
mysql的启动与关闭 启动 /etc/init.d/mysql start 多实例使用自建脚本启动 2种关闭数据库方法 mysqladmin -uroot -p密码 shutdown #优雅关闭/e ...
随机推荐
- php大力力 [023节]CREATE TABLE创建新表sql写字段备注(2015-08-27)
2015-08-27 php大力力023.CREATE TABLE创建新表sql写字段备注 http://www.cnblogs.com/dalitongxue/p/4762182.html 参考: ...
- LeetCode----3 Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...
- HDOJ-三部曲-1002-Radar Installation
Radar Installation Time Limit : 2000/1000ms (Java/Other) Memory Limit : 20000/10000K (Java/Other) ...
- 【LeetCode】Best Time to Buy and Sell Stock IV
Best Time to Buy and Sell Stock IV Say you have an array for which the ith element is the price of a ...
- ERP权限设置和CRM分析 (十二)
个人信息管理: 需求描述: 1.在权限信息表添加一条个人信息修改权限. 2.在TreeMenu表添加一条数据作为个"人信息修改"菜单. 3. 人事登记人员在登记员工信息的时候,自动 ...
- OC多线程管理
在OC中多线程管理包含GCD.NSThread.NSOperationQueue. 下面简单介绍. 进程和线程 进程:正在进行中的程序叫做进程,负责程序运行的内存分配. 每一个进程都有自己独立的虚拟内 ...
- Windows 7下安装部署NodeJs
第一步 安装NodeJs http://nodejs.org/download/ 下载windows版本的msi文件,双击进行安装即可.安装完毕,默认安装路径为C:\Program Files\no ...
- PostgreSQL增删数据命令示例
在PostgreSQL中如何用简单的几条SQL语句生成大量的测试数据呢? 此处,我简单的写一个例子,供参考(在Postgresql9.1下面做的): (1)生成一万条测试数据的表foo mydb=# ...
- (实用篇)php处理单文件、多文件上传代码分享
php处理 单文件.多文件上传实例代码,供大家参考,具体内容如下 后台处理文件submit_form_process.php <?php /************************** ...
- 纯代码写UI的时候,如何指定style?
有的时候,需要使用纯代码实现Android UI,那么这个时候如何指定某个UI组件的样式呢? 一般来说,UI组件都有一些set方法可供使用,以调整一些UI属性,从而达到调整样式的目的. 但是,情况并非 ...