- 复制表结构 + 表数据
Mysql> create tables t2 like t1;
Mysql> insert into t2 select * from t1; - mysql 索引
a、Alert Table 用来创建普通索引、Unique 唯一索引 (当前列数值不可重复) 或 Primary Key 主键索引
Mysql> alter table table_name add index index_name(column_list);
Mysql> alter table table_name add Unique(column_list);
Mysql> alter table table_name add Primary Key(column_list);
b、creat index (不可处理主键索引)
Mysql> create index index_name on table_name(column_list);
Mysql> create Unique index index_name on table_name(column_list);
c、drop index(不可处理主键索引)
Mysql> drop index index_name on table_name;
d、alter table drop
Mysql> alter table table_name drop index index_name;
Mysql> alter table table_name drop primary key; - mysql 视图
创建视图 (视图可根据主表实时更新)
Mysql> create view v_t1 as select * from t1 where id>4 and id <11;
Mysql> show tables;
Mysql> show create view v_t1;
Mysql> drop view v_t1; - Mysql 内置函数
concat ("string1","string2") // 链接字符串
lcase(STRING) // 转换小写
ucase(string) // 转换大写
length(string) //string 长度
ltrim(string) // 去除 string 前面空格
rtrim(string) // 去除 string 后面空格
repeat(string,count) // 重复 string count 次
replace(str,search_str,replace_str) //str 中用 replace_str 替换 search_str - mysql 预处理语句
设置 stmt1 预处理,传递一个数据作为 where 判断条件
Mysql> prepare stmt1 from 'select * from t1 where id>?';
设置一个变量
Mysql> set @i=5;
执行 stmt1 预处理
Mysql> execute stmt1 using @i;
删除预处理 stmt1
Mysql> drop prepare stmt1; - mysql 事务处理 (Engine=MyISAM 表引擎不支持事务机制)
查看表引擎是否支持
Mysql> show create table t1;
设置表引擎为 innodb
Mysql> alter table t1 engine=innodb;
关闭自动提交功能
Mysql> set autocommit=0;
查看当前 autocommit 设置
Mysql> select @@autocommit;
提交
Mysql> commit;
从表 t1 中删除了一条记录
Mysql> delete from t1 where id =11;
此时做一个 p1 还原点
Mysql> savepoint p1;
再次从表 t1 中删除一条记录
Mysql> delete from t1 where id =10;
再次做一个 p2 还原点
Mysql> savepoint p2;
此时恢复到 p1 还原点,当然后面 p2 这些还原点自动失效
Mysql> rollback to p1;
退回到最原始的还原点
Mysql>roolback; - Mysql 存储 (批量处理)
例子:创建存储 P1, 创建 100 个用户;
Mysql> \d // 执行 “;” 临时替换为 “//”
Mysql> create proceduce p1()
->begin
->set @i=1;
->while @i<100 do
->insert into t1(name) value(concat("user",@i));
->set @i=@i+1;
->end while;
->end//
Mysql> \d ;
查看存储
Mysql> show procedure status\G
Mysql> show create procedure p1\G
执行
Mysql> call p1(); - Mysql 触发器
修改 delimiter 为 //
Mysql> \d //
例子:创建触发器 tg1,当向 t1 表插入数据时,t2 表也被插入数据
Mysql> create trigger tg1 before insert on t1 for each row
->begin
->insert into t2(name) values(new.name);
->end//
Mysql> \d ;
查看触发器
Mysql> show triggers;
删除触发器
Mysql> drop trigger tg1;
创建触发器 tg2,当向 t1 表删除数据时,t2 表也被删除数据
Mysql> create trigger tg2 before delete on t1 for each row
->begin
->delete from t2 where name=old.name;
->end//
创建触发器 tg3,当向 t1 表更新数据时,t2 表也被更新数据
Mysql> create trigger tg3 before update on t1 for each row
->begin
->update t2 set name=new.name where name=old.name;
->end// - 重排 auto_increment
Mysql 数据库自动增长的 ID 恢复重新排序
Mysql> alter table tablename auto_increment = 1;
Other:
联合查询
Mysql> select * from t1 union select *from t2
快速删除
Mysql> truncate table tablename;
Mysql 操作技巧
转载于:https://www.cnblogs.com/Mrhuangrui/p/4570475.html
相关文章:

JS实现复制到剪切板效果
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 代码: <!DOCTYPE html> <html lang"en"><head><meta http-equiv"Content-Type" content"text/html; charsetutf-8" /><meta cha…

如何管理多个Python版本和虚拟环境
Addition January 2019: If you are coming back to this blog after upgrading to macOS Mojave please see this github issue for a solution to the common pyenv ‘zlib not available’ problem.此外,2019年1月:如果在升级到macOS Mojave之后又回到…

linux 下byte,char,unsigned char的区别
在linux中,对byte的定义为无符号char,而char默认为有符号char。 #ifndef BYTE #define BYTE unsigned char #endif以下ZZ百度知道: 在C中,默认的基础数据类型均为signed,现在我们以char为例,说明(signed) c…

词法作用域和动态作用域
JavaScript采用的是词法作用域 1.词法作用域 即函数定义时,即确定的作用域。js中的作用域链,在函数声明时候,就已经确定了,无论函数在何处调用,其作用域变量的查找都是按照定义是包含关系去查找。 2.动态作用域 变量的…

10-18 JS基础复习笔记
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 1.JS类型 Numbel String Boolean Symbol Null Undefined Object(Funtion,Array,Data,Regexp); 2.字符串转数字类型 "122" //122 var a 1 2; console.log(a) //3 3.null 和 u…

vue.js crud_如何使用VS Code和ADO.NET使用ASP.NET Core执行CRUD操作
vue.js crud介绍 (Introduction) In this article we are going to create a web application using ASP.NET Core MVC with the help of Visual Studio Code and ADO.NET. We will be creating a sample Employee Record Management System and performing CRUD operations on…
redis事物命令示例
命令示例: 1. 事务被正常执行:#在Shell命令行下执行Redis的客户端工具。/> redis-cli#在当前连接上启动一个新的事务。redis 127.0.0.1:6379>multiOK#执行事务中的第一条命令,从该命令的返回结果可以看出,该命令并没有立即执…

JS 函数 函数递归
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 重要:函数也是对象,你可以给它们添加属性或者更改它们的属性。 函数内部对象:arguments 解析:函数实际上是访问了函数体中一个名为 arguments 的内部对象…

swift设置启动图不现实_如何通过装饰房屋来开始在Swift中使用增强现实
swift设置启动图不现实by Ranadhir Dey由Ranadhir Dey 如何通过装饰房屋来开始在Swift中使用增强现实 (How to get started with augmented reality in Swift by decorating your home) If you’ve read my previous post, you already have a beautiful AR floor in your din…

可用于nodejs的SuperAgent(ajax API)
简单示例: import request from superagent;//引用声明 request.post(api).withCredentials()//跨域.end((err, res) > {if (res.ok) {const json JSON.parse(res.text);} else {console.log(获取失败);}}); 1、get 方式 当使用get请求传递查询字符串的时候&…

Java第四次实验
一、实验内容: 结对编程。运行TCP代码,结对进行,一人服务器,一人客户端;利用加解密代码包,编译运行代码,一人加密,一人解密; 集成代码,密后通过TCP发送。 二、…

JS 面向对象编程之原型(prototype)
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 function Person(first, last) {this.first first;this.last last; } Person.prototype.fullName function() {return this.first this.last; } Person.prototype.fullNameReversed function() {…

idea自动捕获_Smilefie:如何通过检测微笑来自动捕获自拍
idea自动捕获by Rishav Agarwal通过里沙夫阿加瓦尔 Smilefie:如何通过检测微笑来自动捕获自拍 (Smilefie: how you can auto-capture selfies by detecting a smile) Ten second takeaway: use Python and OpenCV to create an app that automatically captures a …

hiho 1015 KMP算法 CF 625 B. War of the Corporations
#1015 : KMP算法 时间限制:1000ms单点时限:1000ms内存限制:256MB描述 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。 这一天,他们遇到了一只河蟹&#…

React 组件绑定点击事件,并且传参完整Demo
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 1.传数组下标给点击事件Demo: const A 65 // ASCII character codeclass Alphabet extends React.Component {constructor(props) {super(props);this.handleClick this.handleClick.bind…

ScaleYViewPager
https://github.com/eltld/ScaleYViewPager 转载于:https://www.cnblogs.com/eustoma/p/4572925.html

node mongoose_如何使用Express,Mongoose和Socket.io在Node.js中构建实时聊天应用程序
node mongooseby Arun Mathew Kurian通过阿伦马修库里安(Arun Mathew Kurian) 如何使用Express,Mongoose和Socket.io在Node.js中构建实时聊天应用程序 (How to build a real time chat application in Node.js using Express, Mongoose and Socket.io) In this tut…

结对项目开发电梯调度 - 整体设计
一、系统介绍 1. 功能描述 本电梯系统用来控制一台运行于一个具有16层的大楼电梯,它具有上升、下降、开门、关门、载客的基本功能。 大楼的每一层都有: (1) 两个指示灯: 这两个指示灯分别用于指示当前所在的层数和电梯的当前状态ÿ…

3.分支结构与循环结构
1 程序结构 程序结构分为顺序结构、分支结构、循环结构。分支结构有:if结构,if....else结构,if...else if....else ,if...else结构,switch结构;循环结构有:while循环,do....while循环…

微信小程序 实现复制到剪贴版功能
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 实现API: wx.setClipboardData(Object object) API说明:设置系统剪贴板的内容 属性类型默认值是否必填说明支持版本datastring 是剪贴板的内容 successfunction 否接口调用成功…

数据结构面试题编程题_您下次编程面试时应该了解的顶级数据结构
数据结构面试题编程题by Fahim ul Haq通过Fahim ul Haq Niklaus Wirth, a Swiss computer scientist, wrote a book in 1976 titled Algorithms Data Structures Programs.瑞士计算机科学家Niklaus Wirth在1976年写了一本书,名为《 算法数据结构程序》。 40 yea…

oracle使用小技巧
批量禁用触发器 SELECT ALTER TRIGGER || trigger_name || DISABLE; FROM all_triggers; 这样就生成了一个禁用语句列表,复制到sql脚本执行界面,批量执行即可,类似的,可以用all_tables来批量删除表。 转载于:https://www.cnblogs…

if for switch语句
顺序语句:一行行执行条件语句:选择分支if语句 1、 if(....)//括号内是判断条件 { //程序代码,运算等等 } 2、 if(....)//括号内是判断条件 { //程序代码,运算等等 } else//如果不满足条件则执…

Apache Unable to find the wrapper https - did you forget to enable it when you configured PHP?
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 Apache Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? 问题解决办法: 打开配置文件 php.ini , 如图: …

文件魔术数字_如何使用魔术脚手架自动创建文件并节省时间
文件魔术数字Before we begin: This article uses JavaScript / Node.js example code, but you can port these concepts to any language using the right tools.开始之前:本文使用JavaScript / Node.js示例代码,但是您可以使用正确的工具将这些概念移…

Sql Server统计报表案例
场景:查询人员指定年月工作量信息 USE [Test] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER procedure [dbo].[GetWorkLoadMain] year int, month int, UserId varchar(50) as begindeclare day varchar(50)set dayCAST(year as varchar)-RIGHT((00…

运行报表时提示输入用户名和密码
在AX2012运行报表是总是提示用户输入用户名和密码: 尝试输入登陆名和密码,点击查看报表,出现如下错误: 因为AX2012的报表使用的针对AX2012客制化的SSRS,而要求输入登录名和密码是SSRS报表的数据源设置导致的。在SSRS管…

CSS 文字,边框实现从左至右颜色渐变
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 1.文本从左至右颜色渐变 效果图: 2.边框从左至右颜色渐变 效果图: 实现代码: 1.文本从左至右颜色渐变实现代码: <!DOCTYPE html> <html>&l…

如何使用Create-React-App和自定义服务人员构建PWA
Note: This is not a primer on create-react-app or what a service worker is. This post assumes prior knowledge of both.注意:这不是create-react-app或服务工作者的入门。 这篇文章假定两者都有先验知识。 So, I recently had the opportunity to work on a…

inline-block空隙怎么解决
方法一:移除空格 元素间留白间距出现的原因就是标签段之间的空格,因此,去掉HTML中的空格,自然间距就木有了。考虑到代码可读性,显然连成一行的写法是不可取的,我们可以: <div class"spa…