第一组:
第二组:冯佳丽 oracle操作语句
——转载
oracle获取上周一和周末日期
select trunc(sysdate,'iw') - 7 from dual;---上周一
select trunc(sysdate,'iw') - 1 from dual;--上周日
oracle获取上个月第一天和最后一天
select trunc(add_months(sysdate, -1), 'mm') first_day,trunc(last_day(add_months(sysdate, -1))) last_day from dual;
oracle 按每天,每周,每月,每季度,每年查询统计数据
//按天统计
select count(dataid) as 每天操作数量, sum() from tablename group by trunc(createtime, 'DD'))
//按自然周统计
select to_char(date,'iw'),sum() from tablename group by to_char(date,'iw')
//按自然月统计
select to_char(date,'mm'),sum() from tablename group by to_char(date,'mm')
//按季统计
select to_char(date,'q'),sum() from tablename group by to_char(date,'q')
//按年统计
select to_char(date,'yyyy'),sum() from tablename group by to_char(date,'yyyy')
add_months(x,y)或者add_months(times,months)函数:
介绍:这个函数用于计算在时间x基础上y个月后的时间值,要是Y的值为负数的话就是在
这个时间点之间的时间值(这个时间-Y个月)。
oracle创建表和复制表数据
create table new_tablename as select * from old_tablename where 0=1;
insert into new_tablename select * from old_tablename where 字段<行数
创建用户和授权
create user username identified by password;
grant dba to username;
alert user scott identified by tiger;//修改密码
sys;//系统管理员,拥有最高权限
system;//本地管理员,次高权限
scott;//普通用户,密码默认为tiger,默认未解锁
grant create session to zhangsan;//授予zhangsan用户创建session的权限,即登陆权限
grant unlimited tablespace to zhangsan;//授予zhangsan用户使用表空间的权限
grant create table to zhangsan;//授予创建表的权限
grante drop table to zhangsan;//授予删除表的权限
grant insert table to zhangsan;//插入表的权限
grant update table to zhangsan;//修改表的权限
grant all to public;//这条比较重要,授予所有权限(all)给所有用户(public)
oralce对权限管理比较严谨,普通用户之间也是默认不能互相访问的,需要互相授权
grant select on tablename to zhangsan;//授予zhangsan用户查看指定表的权限
grant drop on tablename to zhangsan;//授予删除表的权限
grant insert on tablename to zhangsan;//授予插入的权限
grant update on tablename to zhangsan;//授予修改表的权限
grant insert(id) on tablename to zhangsan;
grant update(id) on tablename to zhangsan;//授予对指定表特定字段的插入和修改权限,注意,只能是insert和update
grant alert all table to zhangsan;//授予zhangsan用户alert任意表的权限
3.修改密码期限为90天
Alter PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME '90';//90天期限
Alter PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;//永久期限
oracle锁表解锁语句:
--锁表查询SQLSELECT object_name, machine, s.sid, s.serial#
FROM gv$locked_object l, dba_objects o, gv$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid;
--释放SESSION SQL:
--alter system kill session 'sid, serial#';
ALTER system kill session '23, 1647';
SELECT sid, serial#, username, osuser FROM v$session where sid
in(selectsession_idfromv$locked_object);
--kill掉相关的会话
ALTER SYSTEM KILL SESSION '597,1171';
查询表的创建时间:
select created from dba_objects where object_name='大写的表名';
数据库清除缓存:
ALTER SYSTEM FLUSH SHARED_POOL;//共享池(慎用)
ALTER SYSTEM FLUSH BUFFER_CACHE;//
oracle怎么把一列数据插入到另一列:
update [表名] set [另外一列]=[前一列];
oracle给现有的数据增加序号:
update tablename set 序号字段=sequence.NEXTVAL(表可以根据字段排序后给序号)
oracle分组后取第一条数据:
select * from ( select row_number()over(PARTITION by 分组字段 order by 排序字段) rn ,t.* from tablename t ) where rn=1
表关联更新:
update customers a set city_name = (select b.city_name from tmp_cust_city b where b.customer_id = a.customer_id) where exists
(select 1 from tmp_cust_city b where b.customer_id = a.customer_id)
更新超过两个字段:
update customers a
set (city_name, customer_type) = (select b.city_name, b.customer_type
from tmp_cust_city b
where b.customer_id = a.customer_id)
where exists
(select 1 from tmp_cust_city b where b.customer_id = a.customer_id)
oracle创建视图:
create view as select * from tablename where 条件
创建表空间语句:
create tablespace tablespace_name datafile 'E:\DashanWorkspaces\oradata\DBF\ATM.dbf' size 1M autoextend on next 1M maxsize unlimited;
启动和关闭数据库命令:
startup;启动
shut immediate;关闭
oracle建立表空间时的语句:
select dbms_metadata.get_ddl('TABLESPACE','tablespacename') from dual;
oracle扩展表空间时的语句:
alter database datafile '/u01/app/oracle/oradata/orcl/sec_d01.dbf' autoextend on;
非临时表空间:
select file_id from dba_data_files where tablespace_name=
alter database datafile
临时表空间:
select file_id from dba_temp_files where tablespace_name=
alter database tempfile
查看表所占用的空间:
select * from dba_segments s where s.segment_name='表名大写'
plsql查看数据库的版本:
select * from product_component_version;
sql结果中比较开始和结束时间是否在包含当前时间:
case when to_char(sysdate,'hh24:mi') between 开始时间 and 结束时间 then 1 else -1 end
第三组:吴景霞 Angular.forEach用法
- 针对对象循环(key,value)
var values = {name: 'misko', gender: 'male'};
var log = [];
angular.forEach(values, function(value, key) {
this.push(key + ': ' + value);
}, log);
expect(log).toEqual(['name: misko', 'gender: male']);
2.针对对象数组(key,value)
var objs =[{a:1},{a:2}];
angular.forEach(objs, function(data,index,array){
//data等价于array[index]
console.log(data.a+'='+array[index].a);
});
3.针对对象数组(data)
var objs =[{a:1},{a:2}];
angular.forEach(objs, function(data){
console.log(data.a);
});
第四组:傅云 一道网红题的python解法
from time import time
from constraint import *
problem = Problem()
a1 - a10 表示第一题到第十题的答案变量,答案使用“1”表示“A”, “2”表示“B”,以此类推
vars = ["a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10"]
problem.addVariables(vars, [1, 2, 3, 4])
第 2 题
def a2_func(a2, a5):
return (a2 == 1 and a5 == 3) or (a2 == 2 and a5 == 4) or (a2 == 3 and a5 == 1) or (a2 == 4 and a5 == 2)
problem.addConstraint(a2_func, ["a2", "a5"])
第 3 题
def a3_func(a3, a1, a2, a4, a6):
return (a3 == 1 and a6 == a2 == a4 != a3) or (a3 == 2 and a3 == a2 == a4 != a6)
or (a3 == 3 and a3 == a6 == a4 != a2) or (a3 == 4 and a3 == a6 == a2 != a4)
problem.addConstraint(a3_func, ["a3", "a1", "a2", "a4", "a6"])
第 4 题
def a4_func(a4, a1, a2, a5, a6, a7, a9, a10):
return (a4 == 1 and a1 == a5) or (a4 == 2 and a2 == a7) or (a4 == 3 and a1 == a9) or (a4 == 4 and a6 == a10)
problem.addConstraint(a4_func, ["a4", "a1", "a2", "a5", "a6", "a7", "a9", "a10"])
第 5 题
def a5_func(a4, a5, a7, a8, a9):
return (a5 == a8 == 1) or (a5 == a4 == 2) or (a5 == a9 == 3) or (a5 == a7 == 4)
problem.addConstraint(a5_func, ["a4", "a5", "a7", "a8", "a9"])
第 6 题
def a6_func(a6, a1, a2, a3, a4, a5, a8, a9, a10):
return (a6 == 1 and a2 == a4 == a8) or (a6 == 2 and a1 == a6 == a8)
or (a6 == 3 and a3 == a10 == a8) or (a6 == 4 and a5 == a9 == a8)
problem.addConstraint(a6_func, ["a6", "a1", "a2", "a3", "a4", "a5", "a8", "a9", "a10"])
第 7 题
def a7_func(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10):
all_answers = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]
counter = [0, 0, 0, 0]
for a in all_answers:
counter[a - 1] += 1
imin = counter.index(min(counter)) + 1
return ((a7 == 1 and imin == 3) or (a7 == 2 and imin == 2) or (a7 == 3 and imin == 1) or (a7 == 4 and imin == 4))
problem.addConstraint(a7_func, vars)
第 8 题
def a8_func(a8, a1, a2, a5, a7, a10):
adj = lambda x: abs(a1 - x) != 1
return (a8 == 1 and adj(a7)) or (a8 == 2 and adj(a5)) or (a8 == 3 and adj(a2)) or (a8 == 4 and adj(a10))
problem.addConstraint(a8_func, ["a8", "a1", "a2", "a5", "a7", "a10"])
第 9 题
def a9_func(a1, a2, a5, a6, a9, a10):
cond1 = a1 == a6
cond = lambda x: cond1 != (x == a5)
return (a9 == 1 and cond(a6)) or (a9 == 2 and cond(a10)) or (a9 == 3 and cond(a2)) or (a9 == 4 and cond(a9))
problem.addConstraint(a9_func, ["a1", "a2", "a5", "a6", "a9", "a10"])
第 10 题
def a10_func(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10):
all_answers = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]
counter = [0, 0, 0, 0]
for a in all_answers:
counter[a - 1] += 1
delta = abs(max(counter) - min(counter))
return (a10 == 1 and delta == 3) or (a10 == 2 and delta == 2) or (a10 == 3 and delta == 4) or (a10 == 4 and delta == 1)
problem.addConstraint(a10_func, vars)
约束设置完毕,开始求解
start_time = time()
solutions = problem.getSolutions()
elapsed_time = time() - start_time
print("耗时:{0}".format(elapsed_time))
print("可能的解决数量:{0}".format(len(solutions)))
chars = ['A', 'B', 'C', 'D']
for si in range(0, len(solutions)):
print("\n---------- 第 {0} 组结果 ----------".format(si + 1))
s = solutions[si]
for i in range(1, 11):
key = "a" + str(i)
answer = chars[s[key] - 1]
print("第 {0} 题答案:{1}".format(i, answer))
第五组:王炳钧 gridcontrol单元格边框重绘 加宽显示
参考网址: http://blog.csdn.net/u011871201/article/details/70271798
效果图如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System . Drawing . Drawing2D;
using System . Reflection;
using DevExpress . Utils . Paint;
using System . Diagnostics;
namespace text
{
public partial class XtraForm2 : DevExpress.XtraEditors.XtraForm
{
public XtraForm2 ( )
{
InitializeComponent( );
}
private void XtraForm2_Load ( object sender , EventArgs e )
{
FieldInfo fi = typeof ( XPaint ) . GetField ( "graphics" , BindingFlags . Static | BindingFlags . NonPublic );
fi . SetValue ( null , new MyXPaint ( ) );
}
}
//选中单元格边框变宽
public class MyXPaint :XPaint
{
public override void DrawFocusRectangle ( Graphics g , Rectangle r , Color foreColor , Color backColor )
{
base . DrawFocusRectangle ( g , r , foreColor , backColor );
if ( !CanDraw ( r ) )
return;
Brush hb = Brushes . Black;
g . FillRectangle ( hb , new Rectangle ( r . X , r . Y , 2 , r . Height - 2 ) );//Left
g . FillRectangle ( hb , new Rectangle ( r . X , r . Y , r . Width - 2 , 2 ) );//Top
g . FillRectangle ( hb , new Rectangle ( r . Right - 2 , r . Y , 2 , r . Height - 2 ) );//Right
g . FillRectangle ( hb , new Rectangle ( r . X , r . Bottom -2 , r . Width - 2 , 2 ) );//Bottom
}
}
}