常用 SQL语句
Oracle
查看所有表的名字:
select table_name from user_tables;
查询特定表的名字:
select * from (select table_name t from user_tables) newt where newt.t LIKE '%CODE%';
复杂的查询、分组、排序、计算示例:
select (sum(ss)/count(p)) from (select t.provinceid p,sum(t.time_difference)/count(*) ss from mobile_balancequery t
where (t.queryresult = 0 or t.queryresult = 81029) and t.start_querytime > sysdate - 300/1440
group by t.provinceid
order by t.provinceid)
去除重复数据:
delete from mobile_balancequery a
where rowid not in
(select max(rowid) from mobile_balancequery b where a.phonenum = b.phonenum);
commit;
MySQL :
1、查看表的存储引擎
show create table article; -- article 是表名
2、查看所有使用数据库的进程
show processlist;
3、杀死进程
kill 57; -- 57是进程号 可以通过 show processlist 查找
4、查看主从状态
show slave status\G
双yes就是从库,双no可能是主库
5、开启、关闭从库
start slave stop slave
6、MySQL 命令窗登录、退出(exit)
mysql -h192.168.61.28 -P3306 -utest -ptest -- 注意P大写
7、查看表的创建语句
show create table tableName;
8、查看数据库、切换数据库、查看数据库的表
show databases; -- 查看所有数据库名
show tables; -- 查看家数据库中所有表名
use databaseName; -- 切换数据库
9、查看表的大小
-- 首先切换到管理库
use information_schema;
-- 执行如下语句(weather是数据库名,cms_data是表名)
select data_length,index_length
from tables where
table_schema='weather'
and table_name = 'cms_data'; select concat(round(sum(data_length/1024/1024),2),'MB') as data_length_MB,
concat(round(sum(index_length/1024/1024),2),'MB') as index_length_MB
from tables where
table_schema='weather'
and table_name = 'cms_data';
常用 SQL语句的更多相关文章
- Mysql 常用 SQL 语句集锦
Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...
- Mysql 常用 SQL 语句集锦 转载(https://gold.xitu.io/post/584e7b298d6d81005456eb53)
Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...
- 50个常用SQL语句
50个常用SQL语句 Student(S#,Sname,Sage,Ssex) 学生表 S#学号,主键 Course(C#,Cname,T#) 课程表 C#课程号,主键 SC(S#, ...
- oracle sqlplus及常用sql语句
常用sql语句 有需求才有动力 http://blog.csdn.net/yitian20000/article/details/6256716 常用sql语句 创建表空间:create tables ...
- oracle常用SQL语句(汇总版)
Oracle数据库常用sql语句 ORACLE 常用的SQL语法和数据对象一.数据控制语句 (DML) 部分 1.INSERT (往数据表里插入记录的语句) INSERT INTO 表名(字段名1, ...
- 常用SQL语句(增删查改、合并统计、模糊搜索)
转自:http://www.cnblogs.com/ljianhui/archive/2012/08/13/2695906.html 常用SQL语句 首行当然是最基本的增删查改啦,其中最重要的是查. ...
- oracle 常用sql语句
oracle 常用sql语句 1.查看表空间的名称及大小 select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_sizefrom d ...
- Sqlite常用sql语句
sqlite常用sql语句 --返回UTC时间 select CURRENT_TIMESTAMP; --返回本地时间 select datetime(CURRENT_TIMESTAMP,'localt ...
- 常用SQL语句集合
一.数据定义 1.创建新数据库:CREATE DATABASE database_name2.创建新表:CREATE TABLE table_name (column_name datatype,co ...
- 常用sql语句整理:mysql
## 常用sql语句整理:mysql1. 增- 增加一张表```CREATE TABLE `table_name`( ... )ENGINE=InnoDB DEFAULT CHARSET=utf8 ...
随机推荐
- 简单的interface显式和隐式的实现
一,新建接口 using System; using System.Collections.Generic; using System.Linq; using System.Web; /// < ...
- 使用 Spark MLlib 做 K-means 聚类分析[转]
原文地址:https://www.ibm.com/developerworks/cn/opensource/os-cn-spark-practice4/ 引言 提起机器学习 (Machine Lear ...
- 【Sort】HeapSort
堆排序,时间复杂度O(N log N),实际使用中慢于使用Sedgewick增量的增量排序. 大致思路: 1.先在数组中建堆,如果是增量排序,则需要建一个大堆 2.每循环一次,把最大的数,也就是num ...
- hdu_5969_最大的位或(贪心)
题目链接:hdu_5969_最大的位或 题意: 中文,还是自己看 题解: xjb贪心一下就行了 #include<bits/stdc++.h> #define F(i,a,b) for(i ...
- 4、Web应用程序中的安全向量 -- over-posting(重复提交)
模型绑定是ASP.NET MVC提供的强大功能,可遵照命名约定将输入元素映射到模型属性,从而极大地简化了处理用户输入的过程,然而,这也成为了攻击的另一种没接,给攻击者提供了一个填充模型属性的机会,右下 ...
- Entity Framework删除数据
注:本文为个人学习摘录,原文地址:http://blog.csdn.net/itmaxin/article/details/47659817 最近在学EF,目前了解到删除操作有三种方式, 第一,官方推 ...
- COCOA® PROGRAMMING FOR MAC® OS X (2)- Speak Line
1.NSControl是所有控件的父类,NSControl继承自NSView,因此NSControl是一个能够独立响应事件的NSView,每个NSControl含有一个Target和Action,当用 ...
- luci小记
LuCI使用controller目录下的lua脚本中的index函数来构造了一个dispatch树.cgi环境变量PATH_INFO会被用在dispatch树种,例如 cgi-bin/luci/foo ...
- Java ZIP打包
File zipFile = IOUtil.createTempFile("zip"); ZipOutputStream zipout = new ZipOutputStream( ...
- LeetCode OJ 35. Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the ...