当前位置:  编程技术>综合
本页文章导读:
    ▪Django项目5      准备工作 django-admin.py startproject web05 django-admin.py startapp blog blog注册到settings.py中 python manage.py runserver配置url from django.conf.urls.defaults import patterns, include, url urlpatterns = patterns('', url(r'^blog/index.........
    ▪oralce中的join 连接      Joins A join is a query that combines rows from two or more tables, views, or materialized views. Oracle Database performs a join whenever multiple tables appear in the FROM clause of the query. The select list of the query can select any colu.........
    ▪qt 窗口默认居中      添加头文件: #include <QDesktopWidget>   int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); w.move ((QApplication::desktop()->width() - w.width())/2,(QApplication::desktop()->h.........

[1]Django项目5
    来源: 互联网  发布时间: 2013-11-07

准备工作

django-admin.py startproject web05
django-admin.py startapp blog
blog注册到settings.py中
python manage.py runserver
配置url
from django.conf.urls.defaults import patterns, include, url 
urlpatterns = patterns('',
    url(r'^blog/index/$','blog.views.index'),
)
配置views
#coding:utf8
from django.http import HttpResponse
from django.template import loader,Context
import datetime

def index(req):             #req只是用来request而已,用别名也可
    t=loader.get_template('index.html')
    now = datetime.datetime.now()
    emps = [ 
        {}, 
        {}, 
        {}, 
    ]   
    c=Context({
        'a':123,
        'now':now,
    })  
    html = t.render(c)
    return HttpResponse(html)
配置html,过滤器!
<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title></title>
</head>
<body>
{{a|add:'2'}}<br />
{{now|date:'Y m d H i s'}}
</body>
</html>


作者:forgetbook 发表于2013-1-6 17:01:16 原文链接
阅读:40 评论:0 查看评论

    
[2]oralce中的join 连接
    来源: 互联网  发布时间: 2013-11-07
Joins
    A join is a query that combines rows from two or more tables, views, or materialized views. Oracle Database performs a join whenever multiple tables appear 
    in the FROM clause of the query. The select list of the query can select any columns from any of these tables. If any two of these tables have a column name in common, 
    then you must qualify all references to these columns throughout the query with table names to avoid ambiguity.
    
Join Conditions
     Most join queries contain at least one join condition, either in the FROM clause or in the WHERE clause. The join condition compares two columns, each from a different table. 
     1.To execute a join, Oracle Database combines pairs of rows, each containing one row from each table, for which the join condition evaluates to TRUE. 
     The columns in the join conditions need not also appear in the select list.

     2.To execute a join of three or more tables, Oracle first joins two of the tables based on the join conditions comparing their columns and then joins the result 
     to another table based on join conditions containing columns of the joined tables and the new table. 
     Oracle continues this process until all tables are joined into the result. The optimizer determines the order in which Oracle joins tables based on the join conditions, 
     indexes on the tables, and, any available statistics for the tables.

--
连接分类

1.Equijoins  等值连接  示例如下:
An equijoin is a join with a join condition containing an equality operator. 
An equijoin combines rows that have equivalent values for the specified columns. 
Depending on the internal algorithm the optimizer chooses to execute the join, 
the total size of the columns in the equijoin condition in a single table may be limited to the size of a data block minus some overhead. 
The size of a data block is specified by the initialization parameter DB_BLOCK_SIZE.

SELECT last_name, job_id, departments.department_id, department_name
   FROM employees, departments
   WHERE employees.department_id = departments.department_id
   ORDER BY last_name;

SELECT last_name, job_id, departments.department_id, department_name
   FROM employees, departments
   WHERE employees.department_id = departments.department_id
   AND job_id = 'SA_MAN'
   ORDER BY last_name;
   
2.Self Joins  自连接 示例如下:(同一个表的等值连接)
SELECT e1.last_name||' works for '||e2.last_name 
   "Employees and Their Managers"
   FROM employees e1, employees e2 
   WHERE e1.manager_id = e2.employee_id
      AND e1.last_name LIKE 'R%';
      

3.笛卡尔积  Cartesian Products 
3.1 Inner Joins 内连接
    An inner join (sometimes called a simple join) is a join of two or more tables that returns only those rows that satisfy the join condition.
3.2 Outer Joins 外连接 (左外连接,右外连接,全外连接)
An outer join extends the result of a simple join. An outer join returns all rows that satisfy the join condition and also returns some or all of those rows from one table 
for which no rows from the other satisfy the join condition.
    To write a query that performs an outer join of tables A and B and returns all rows from A (a left outer join), use the LEFT [OUTER] JOIN syntax in the FROM clause,
     or apply the outer join operator (+) to all columns of B in the join condition in the WHERE clause. For all rows in A that have no matching rows in B, 
     Oracle Database returns null for any select list expressions containing columns of B.

    To write a query that performs an outer join of tables A and B and returns all rows from B (a right outer join), use the RIGHT [OUTER] JOIN syntax in the FROM clause,
     or apply the outer join operator (+) to all columns of A in the join condition in the WHERE clause. For all rows in B that have no matching rows in A,
      Oracle returns null for any select list expressions containing columns of A.

    To write a query that performs an outer join and returns all rows from A and B, extended with nulls if they do not satisfy the join condition (a full outer join), 
    use the FULL [OUTER] JOIN syntax in the FROM clause.

3.3 Antijoins  反连接
An antijoin returns rows from the left side of the predicate for which there are no corresponding rows on the right side of the predicate. 
That is, it returns rows that fail to match (NOT IN) the subquery on the right side.
反关连的基本语法
反连接是从一个结果集合中返回不在另一个结果集中的数据行。

3.4 Semijoins  半连接

A semijoin returns rows that match an EXISTS subquery without duplicating rows from the left side of the predicate when multiple rows on the right side satisfy the criteria of the subquery.
Semijoin and antijoin transformation cannot be done if the subquery is on an OR branch of the WHERE clause.
在我们查看一个数据集中某些字段存在于另一个数据集合中的记录时,常常会用到in 或者exists。在执行计划中会看到join semi。


3.5  自然连接 natural join

3.6  交叉连接 cross join


-----------------------------------------------------------------

测试

create table stu(
id number(10),
name varchar2(100),
phone varchar2(20)
);

create table cause(
id number(10),
name varchar2(100),
sid number(10)
);

insert into stu values(1,'AAA','123456789');
insert into stu values(2,'BBB','777777777');
insert into stu values(3,'CCC','555555555');
insert into stu values(4,'DDD','222222222');

insert into cause values(1,'JAVA',1);
insert into cause values(2,'HIBERNATE',1);
insert into cause values(3,'ORACLE',2);
insert into cause values(4,'XML',3);
insert into cause values(5,'HTML',0);
commit;



select * from stu;
select * from cause; 



自然连接:将关联对象所有相同名称的列进行等值连接。
insert into stu values(6,'MMMMM','222222222');
insert into cause values(6,'MMMMM',0);
commit;
 select * from stu  natural join cause ;
 select a.*,b.* from stu a natural join cause b;--自然连接的列不能用别名分别指定并显示在select结果中,打印的时候只输出一列
 select a.id,b.name from stu a natural join cause b;
 select id,name from stu a natural join cause b;--资源连接的列不要指定属于哪个对象
 
 select * from stu  natural join cause using(id);--自然连接不能使用usiing
 
等值连接 就是 内连接 ???  从结果上看这两个结果是一样的
select * from stu s,cause c where s.id=c.sid;
select s.*,c.* from stu s,cause c where s.id=c.sid;

select s.*,c.* from stu s,cause c where s.id>c.sid;

内连接 (inner可以省略)
select * from stu s inner join cause c on s.id=c.sid;
select * from stu s join cause c on s.id=c.sid;

select * from stu s join cause c on s.id>c.sid;

select * from stu s join cause c on s.id=c.id;
select * from stu s join cause c  using(id);
select s.*,c.* from stu s join cause c  using(id);--using用到的列在select时不能指定所属表,打印的时候只输出一列
select * from stu s join cause c  using(id,name);

select * from stu s inner join cause c on s.id=c.sid where s.name='AAA';
select * from stu s join cause c on s.id=c.sid;

外连接  --用using的话要保证对象之间有相同的列明
左外连接 
select * from stu s left outer join cause c on s.id=c.sid;
select * from stu s,cause c where s.id=c.sid(+);

select * from stu s left outer join cause c using(id);--用using的话要保证对象之间有相同的列明

右外连接
select * from stu s right outer join cause c on s.id=c.sid;
select * from stu s,cause c where s.id(+)=c.sid;

全外连接  等于左连接和右连接的union
select * from stu s full outer join cause c on s.id=c.sid;

select * from stu s,cause c where s.id=c.sid(+)
union all
select * from stu s,cause c where s.id(+)=c.sid;

select * from stu s,cause c where s.id=c.sid(+)
union 
select * from stu s,cause c where s.id(+)=c.sid;


交叉连接=笛卡尔积
select * from stu s cross join cause c; 
select * from stu s , cause c; --不写where条件


反连接
Using Antijoins: Example The following example selects a list of employees who are not in a particular set of departments:

SELECT * FROM employees 
   WHERE department_id NOT IN 
   (SELECT department_id FROM departments 
       WHERE location_id = 1700)
   ORDER BY last_name;

半连接
Using Semijoins: Example In the following example, only one row needs to be returned from the departments table, even though many rows in the employees table might match the subquery. If no index has been defined on the salary column in employees, then a semijoin can be used to improve query performance.

SELECT * FROM departments 
   WHERE EXISTS 
   (SELECT * FROM employees 
       WHERE departments.department_id = employees.department_id 
       AND employees.salary > 2500)
   ORDER BY department_name; 




注意事项:
1、如果在使用using关键字时,而且select的结果列表项中包含了using关键字所指明的那个关键字,那么请不要在select的结果列表项中对该关键字指明它属于哪个表。
2、using中仅能使用一个列名。
3、natural join关键字和using关键字是互斥的,也就是说不能同时出现。


作者:Rookie_CEO 发表于2013-1-6 16:54:37 原文链接
阅读:40 评论:0 查看评论

    
[3]qt 窗口默认居中
    来源: 互联网  发布时间: 2013-11-07

添加头文件:

#include <QDesktopWidget>

 

int main(int argc, char *argv[])

{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    w.move ((QApplication::desktop()->width() - w.width())/2,(QApplication::desktop()->height() - w.height())/2);
    return a.exec();
}


        
作者:aile770339804 发表于2013-1-6 16:50:57 原文链接
阅读:42 评论:0 查看评论

    
最新技术文章:
▪error while loading shared libraries的解決方法    ▪版本控制的极佳实践    ▪安装多个jdk,多个tomcat版本的冲突问题
▪简单选择排序算法    ▪国外 Android资源大集合 和个人学习android收藏    ▪.NET MVC 给loading数据加 ajax 等待loading效果
▪http代理工作原理(3)    ▪关注细节-TWaver Android    ▪Spring怎样把Bean实例暴露出来?
▪java写入excel2007的操作    ▪http代理工作原理(1)    ▪浅谈三层架构
▪http代理工作原理(2)    ▪解析三层架构……如何分层?    ▪linux PS命令
▪secureMRT Linux命令汉字出现乱码    ▪把C++类成员方法直接作为线程回调函数    ▪weak-and算法原理演示(wand)
▪53个要点提高PHP编程效率    ▪linux僵尸进程    ▪java 序列化到mysql数据库中
▪利用ndk编译ffmpeg    ▪活用CSS巧妙解决超长文本内容显示问题    ▪通过DBMS_RANDOM得到随机
▪CodeSmith 使用教程(8): CodeTemplate对象    ▪android4.0 进程回收机制    ▪仿天猫首页-产品分类
▪从Samples中入门IOS开发(四)------ 基于socket的...    ▪工作趣事 之 重装服务器后的网站不能正常访...    ▪java序列化学习笔记
▪Office 2010下VBA Addressof的应用    ▪一起来学ASP.NET Ajax(二)之初识ASP.NET Ajax    ▪更改CentOS yum 源为163的源
▪ORACLE 常用表达式    ▪记录一下,AS3反射功能的实现方法    ▪u盘文件系统问题
▪java设计模式-观察者模式初探    ▪MANIFEST.MF格式总结    ▪Android 4.2 Wifi Display核心分析 (一)
▪Perl 正则表达式 记忆方法    ▪.NET MVC 给loading数据加 ajax 等待laoding效果    ▪java 类之访问权限
▪extjs在myeclipse提示    ▪xml不提示问题    ▪Android应用程序运行的性能设计
▪sharepoint 2010 自定义列表启用版本记录控制 如...    ▪解决UIScrollView截获touch事件的一个极其简单有...    ▪Chain of Responsibility -- 责任链模式
▪运行skyeye缺少libbfd-2.18.50.0.2.20071001.so问题    ▪sharepoint 2010 使用sharepoint脚本STSNavigate方法实...    ▪让javascript显原型!
▪kohana基本安装配置    ▪MVVM开发模式实例解析    ▪sharepoint 2010 设置pdf文件在浏览器中访问
▪spring+hibernate+事务    ▪MyEclipse中文乱码,编码格式设置,文件编码格...    ▪struts+spring+hibernate用jquery实现数据分页异步加...
▪windows平台c++开发"麻烦"总结    ▪Android Wifi几点    ▪Myeclipse中JDBC连接池的配置
▪优化后的冒泡排序算法    ▪elasticsearch RESTful搜索引擎-(java jest 使用[入门])...    ▪MyEclipse下安装SVN插件SubEclipse的方法
▪100个windows平台C++开发错误之七编程    ▪串口转以太网模块WIZ140SR/WIZ145SR 数据手册(版...    ▪初识XML(三)Schema
▪Deep Copy VS Shallow Copy    ▪iphone游戏开发之cocos2d (七) 自定义精灵类,实...    ▪100个windows平台C++开发错误之八编程
▪C++程序的内存布局    ▪将不确定变为确定系列~Linq的批量操作靠的住...    ▪DIV始终保持在浏览器中央,兼容各浏览器版本
▪Activity生命周期管理之三——Stopping或者Restarti...    ▪《C语言参悟之旅》-读书笔记(八)    ▪C++函数参数小结
▪android Content Provider详解九    ▪简单的图片无缝滚动效果    ▪required artifact is missing.
▪c++编程风格----读书笔记(1)    ▪codeforces round 160    ▪【Visual C++】游戏开发笔记四十 浅墨DirectX教程...
▪【D3D11游戏编程】学习笔记十八:模板缓冲区...    ▪codeforces 70D 动态凸包    ▪c++编程风格----读书笔记(2)
▪Android窗口管理服务WindowManagerService计算Activity...    ▪keytool 错误: java.io.FileNotFoundException: MyAndroidKey....    ▪《HTTP权威指南》读书笔记---缓存
▪markdown    ▪[设计模式]总结    ▪网站用户行为分析在用户市场领域的应用
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3