2018-03-12 oracle操作语句、Angular.forEach用法、一道网红题的python解法、gridcontrol单元格边框重绘 加宽显示

第一组:


第二组:冯佳丽 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=<your_tablespace_name>;

alter database datafile <file_id> autoextend on next 10M maxsize 10G;

临时表空间:

select file_id from dba_temp_files where tablespace_name=<your_tablespace_name>;

alter database tempfile <file_id> autoextend on next 10M maxsize 10G;

查看表所占用的空间:

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用法

  1. 针对对象循环(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      
        }  
    }  
}  
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,185评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,445评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,684评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,564评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,681评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,874评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,025评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,761评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,217评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,545评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,694评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,351评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,988评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,778评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,007评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,427评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,580评论 2 349

推荐阅读更多精彩内容