
sql语句
tuzhg
这个作者很懒,什么都没留下…
展开
-
获取当前字段第二多的记录
我们经常要考虑到数据库重复的原因 假设我们要获取薪水第二多的员工的emp_no,salary 其中salaries是薪水表这是错误的写法 select emp_no ,salary from salaries order by salary desc limit 1,1;//limit m,n;是取第m+1条开始的n条记录 ,order by salary 以薪水排序 desc倒序这种写原创 2017-11-17 11:37:41 · 330 阅读 · 0 评论 -
mysql添加列到指定位置
添加到某列后面alter table tset_table add age int(4) default 20 after id;将age添加到变test_table 中id的后面 其中default 为默认值如果想将某列添加为第一列alter table test_table add test int (5) default 4 first原创 2017-11-13 17:23:45 · 18114 阅读 · 0 评论 -
oracle删除重复数据
--比如要删除name相同的数据只留下一条select name from test11 group by name having count(name) >1 --查出重复的记录select name, min(rowid) id from test11 ;where name in (select name from test11 group by name having...原创 2018-03-19 09:57:56 · 196 阅读 · 0 评论 -
union all 和 order by 连用
select * from (select * from test order by column_id) union all select 'test' from dual; --镶嵌一个子查询就能和union all连用 ...原创 2018-07-25 15:16:13 · 407 阅读 · 0 评论 -
统计表数据量的存储过程
----------将owner.table_name插入到test表中,在protest表中可以得到相应统计结果create or replace procedure testtt as cursor test_cursor is select a from test; v_sql1 varchar(500);begin execute immediate 'trunc...原创 2018-08-30 09:57:24 · 1170 阅读 · 0 评论