A SQL to insert continuous values
I need a table to store all the working days. I dont like loop, so I tried sql. The following is the SQL I used.
insert into tb_working_days(data_date,day_type)
select DATE_ADD(data_date,INTERVAL (select count(1) from tb_working_days) day),"W"
from tb_working_days ;
At first, I insert one date into the table.
Then I run this sql once, I get two rows. Run once more, I get four rows, as so on.
after 10 runs, I get more than 1000 rows. the work is done.
The most interesting point is the sql after Interval, and it makes the magic. The db is smart enough to convert a set into a int. that is amazing.
A SQL to insert continuous values的更多相关文章
- sql动态insert向varchar(MAX)中写入据的问题
sql动态insert向varchar(MAX)中写入据的问题,在写入时出现列无效.后来发现,varchar要加''两个,号才可以 SET @SQL='INSERT INTO '+@TabName+' ...
- SQL Server Insert操作中的锁
原文:SQL Server Insert操作中的锁 这篇博文简单介绍一下在SQL Server中一条Insert语句中用到的锁. 准备数据 首先我们建立一张表Table_1,它有两列Id(bigint ...
- ORA-00913错误:PL/SQL: ORA-00913: too many values
ORA-00913错误 描写叙述:PL/SQL: ORA-00913: too many values 目标:编写一个能够循环插入数据的脚本 操作过程: SQL> desc tcustmer N ...
- Delphi X10.2 + FireDAC 使用 SQL 语句 INSERT
// CREATE TABLE [tabusers]( // [id] INTEGER PRIMARY KEY AUTOINCREMENT, // [username] CHAR NOT NULL, ...
- Mybatis执行sql(insert、update、delete)返回值问题
数据库:Mysql 在使用mybatis的过程中对执行sql的返回值产生疑问,顺手记录一下. 结论: insert: 插入n条记录,返回影响行数n.(n>=1,n为0时实际为插入失败) up ...
- sql学习--insert
insert的四种插入方式 第一种最简单的 into 和目标列的列表是可选的 intsert [into] tableA [(col1,col2)] values(val1,val2) 第二种 ins ...
- sql在insert时判断有无唯一性冲突
sql在insert时判断有无唯一性冲突,存在相同主键或唯一索引,则不创建 INSERT INTO table(field1, field2, fieldn) SELECT 'field1', 'fi ...
- sql server insert values 多值 与oracle 的不同
类似的语句在 oracle 中是不能执行的 insert into temp_tbl values('app'),('demo'); 但是在sql server 中是可以的 insert into c ...
- FMDB存储模型对象(以二进制存储)用NSKeyedArchiver archivedDataWithRootObject序列号,NSKeyedUnarchiver unarchiveObjectWithData反序列化(重点坑是sql语句@"insert into t_newsWithChannel (nwesName,newsType) values (?,?)")一定要用占位符
交友:微信号 dwjluck2013 一.封装FMDB单例 (1)JLFMDBHelp.h文件 #import <Foundation/Foundation.h> #import < ...
随机推荐
- cdoj844-程序设计竞赛 (线段树的区间最大连续和)【线段树】
http://acm.uestc.edu.cn/#/problem/show/844 程序设计竞赛 Time Limit: 3000/1000MS (Java/Others) Memory L ...
- Hamburgers
Hamburgers http://codeforces.com/problemset/problem/371/C time limit per test 1 second memory limit ...
- dede搜索页面上某些标签无法使用
dede默认的搜索模板是search.htm,但在模板文件中使用{dede:type}{/dede:type}或{dede:flink}{/dede:flink}时,发现标签并没有被解析,显示为空. ...
- Golang之写一个聊天室
. 海量用户在线聊天系统 . 点对点聊天 . 用户登录&注册 一.服务端开发 . 用户管理 用户id:数字 用户密码:字母数字组合 用户昵称:用来显示 用户性别:字符串 用户头像:url 用户 ...
- Luogu 3953[NOIP2017] 逛公园 堆优化dijkstra + 记忆化搜索
题解 首先肯定是要求出单源最短路的,我用了堆优化dijikstra ,复杂度 mlogm,值得拥有!(只不过我在定义优先队列时把greater 打成了 less调了好久 然后我们就求出了$i$到源点的 ...
- 如何在win 2008 server和win 7上add web site
在 windows 2008 server 英文版的操作系统上,通过桌面上的 Computer 右键选择 Manage ,打开 Server Manager,选中左侧资源树中的Roles 在上图右侧 ...
- 不能错过的Sketch实用新技巧和资源集锦
Sketch是一款基于Mac的矢量绘图应用.面对着功能复杂繁琐的photoshop,Sketch相比较而言身轻如燕.最近也掀起了用Sketch设计产品原型的热潮,因为用它来画设计稿简直轻而易举,相比于 ...
- 转载hibernate 的3种 状态 。。
转自 http://huangtut.iteye.com/blog/261520 对我有帮助,所以收藏了 Hibernate三种状态的区分,以及save,update,saveOrUpdate,m ...
- <td> 行高多层设置的问题
在一个table中,设置了class,并且对应的样式设置了td的高度时,在其嵌套的table中的td高度不能设置大于父table的td的高度. 只有一种方法可以设置,如下: <table wid ...
- Quartz教程三:Job与JobDetail介绍
Quartz教程三:Job与JobDetail介绍 原文链接 | 译文链接 | 翻译:nkcoder | 校对: 本系列教程由quartz-2.2.x官方文档翻译.整理而来,希望给同样对quartz感 ...