有一种合并维度的情况,就是本来属性相同的维度,因为某种原因被设计成重复的维度属性。例如,在销售订单示例中,随着数据仓库中维度的增加,我们会发现有些通用的数据存在于多个维度中。客户维度的客户地址相关信息、送货地址相关信息里都有邮编、城市和省份。下面说明如何把客户维度里的两个邮编相关信息合并到一个新的维度中。

一、修改数据仓库表结构

为了合并维度,需要改变数据仓库表结构。图1显示了修改后的结构。新增了一个zip_code_dim邮编信息维度表,sales_order_fact事实表的结构也做了相应的修改。


图1

zip_code_dim维度表与销售订单事实表相关联。这个关系替换了事实表与客户维度的关系。sales_order_fact表需要两个关系,一个关联到客户地址邮编,另一个关联到送货地址邮编,相应的增加了两个外键字段。假设邮编相关信息不会修改,因此zip_code_dim表中没有是否删除、版本号、生效日期等SCD属性。
        下面的脚本用于修改数据仓库模式,所做的修改如下。

  • 创建邮编维度表zip_code_dim。
  • 初始装载邮编相关数据。
  • 基于zip_code_dim表创建v_customer_zip_code_dim和v_shipping_zip_code_dim视图。
  • 在sales_order_fact表上增加customer_zip_code_sk和shipping_zip_code_sk列。
  • 基于已有的客户邮编和送货邮编初始装载两个邮编代理键。
  • 在customer_dim表上删除客户和送货邮编及其它们的城市和州列。
  • 在pa_customer_dim上删除客户的城市、州和邮编列。
  1. set search_path=tds;
  2.  
  3. -- 建立邮编维度表
  4. create table zip_code_dim
  5. (
  6. zip_code_sk serial,
  7. zip_code int,
  8. city varchar(30),
  9. state varchar(2)
  10. );
  11.  
  12. comment on table zip_code_dim is '邮编维度表';
  13. comment on column zip_code_dim.zip_code_sk is '邮编维度代理键';
  14. comment on column zip_code_dim.zip_code is '邮编';
  15. comment on column zip_code_dim.city is '城市';
  16. comment on column zip_code_dim.state is '省份';
  17.  
  18. -- 初始装载邮编相关数据
  19. insert into zip_code_dim (zip_code, city, state)
  20. select distinct *
  21. from (select customer_zip_code, customer_city, customer_state
  22. from customer_dim
  23. where customer_zip_code is not null
  24. union all
  25. select shipping_zip_code, shipping_city, shipping_state
  26. from customer_dim
  27. where shipping_zip_code is not null) t1;
  28.  
  29. -- 创建视图
  30. create view v_customer_zip_code_dim
  31. (customer_zip_code_sk, customer_zip_code, customer_city, customer_state) as
  32. select * from zip_code_dim;
  33.  
  34. create view v_shipping_zip_code_dim
  35. (shipping_zip_code_sk, shipping_zip_code, shipping_city, shipping_state) as
  36. select * from zip_code_dim;
  37.  
  38. -- 添加邮编代理键
  39. alter table sales_order_fact add column customer_zip_code_sk int default null;
  40. alter table sales_order_fact add column shipping_zip_code_sk int default null;
  41.  
  42. comment on column sales_order_fact.customer_zip_code_sk is '客户邮编代理键';
  43. comment on column sales_order_fact.shipping_zip_code_sk is '送货邮编代理键';
  44.  
  45. -- 初始装载两个邮编代理键
  46. create table sales_order_fact_bak as select * from sales_order_fact;
  47. truncate table sales_order_fact;
  48.  
  49. insert into sales_order_fact
  50. select t1.order_number,
  51. t1.customer_sk,
  52. t1.product_sk,
  53. t1.order_date_sk,
  54. t1.year_month,
  55. t1.order_amount,
  56. t1.order_quantity,
  57. t1.request_delivery_date_sk,
  58. t1.sales_order_attribute_sk,
  59. t2.customer_zip_code_sk,
  60. t3.shipping_zip_code_sk
  61. from sales_order_fact_bak t1
  62. left join
  63. (select a.order_number order_number,c.customer_zip_code_sk customer_zip_code_sk
  64. from sales_order_fact_bak a,
  65. customer_dim b,
  66. v_customer_zip_code_dim c
  67. where a.customer_sk = b.customer_sk
  68. and b.customer_zip_code = c.customer_zip_code) t2 on t1.order_number = t2.order_number
  69. left join
  70. (select a.order_number order_number,c.shipping_zip_code_sk shipping_zip_code_sk
  71. from sales_order_fact_bak a,
  72. customer_dim b,
  73. v_shipping_zip_code_dim c
  74. where a.customer_sk = b.customer_sk
  75. and b.shipping_zip_code = c.shipping_zip_code) t3 on t1.order_number = t3.order_number;
  76.  
  77. drop table sales_order_fact_bak;
  78.  
  79. -- customer_dim表上删除客户和送货邮编及其它们的城市和州列。
  80. alter table customer_dim drop column customer_zip_code cascade;
  81. alter table customer_dim drop column customer_city;
  82. alter table customer_dim drop column customer_state;
  83. alter table customer_dim drop column shipping_zip_code;
  84. alter table customer_dim drop column shipping_city;
  85. alter table customer_dim drop column shipping_state;
  86.  
  87. alter table pa_customer_dim drop column customer_zip_code;
  88. alter table pa_customer_dim drop column customer_city;
  89. alter table pa_customer_dim drop column customer_state;
  90. alter table pa_customer_dim drop column shipping_zip_code;
  91. alter table pa_customer_dim drop column shipping_city;
  92. alter table pa_customer_dim drop column shipping_state;
  93.  
  94. -- 重建相关视图
  95. create or replace view v_customer_dim_latest as
  96. select customer_sk,
  97. customer_number,
  98. customer_name,
  99. customer_street_address,
  100. version,
  101. effective_date,
  102. shipping_address
  103. from (select distinct on (customer_number) customer_number,
  104. customer_sk,
  105. customer_name,
  106. customer_street_address,
  107. isdelete,
  108. version,
  109. effective_date,
  110. shipping_address
  111. from customer_dim
  112. order by customer_number, customer_sk desc) as latest
  113. where isdelete is false;
  114.  
  115. create or replace view v_customer_dim_his as
  116. select *, date(lead(effective_date,1,date '2200-01-01') over (partition by customer_number order by effective_date)) expiry_date
  117. from customer_dim;
  118.  
  119. create or replace view v_pa_customer_dim_latest as
  120. select customer_sk,
  121. customer_number,
  122. customer_name,
  123. customer_street_address,
  124. version,
  125. effective_date,
  126. shipping_address
  127. from (select distinct on (customer_number) customer_number,
  128. customer_sk,
  129. customer_name,
  130. customer_street_address,
  131. isdelete,
  132. version,
  133. effective_date,
  134. shipping_address
  135. from pa_customer_dim
  136. order by customer_number, customer_sk desc) as latest
  137. where isdelete is false;
  138.  
  139. create or replace view v_pa_customer_dim_his as
  140. select *, date(lead(effective_date,1,date '2200-01-01') over (partition by customer_number order by effective_date)) expiry_date
  141. from pa_customer_dim;

说明:

  • 邮编维度的初始数据是从客户维度表中来,这只是为了演示数据装载的过程。客户的邮编信息很可能覆盖不到所有邮编,所以更好的方法是装载一个完整的邮编信息表。由于客户地址和送货地址可能存在交叉的情况,因此使用distinct去重。送货地址的三个字段是后加的,在此之前数据的送货地址为空,邮编维度表中不能含有NULL值,所以要加上where shipping_zip_code is not null过滤条件去除邮编信息为NULL的数据行。
  • 基于邮编维度表创建客户邮编和送货邮编视图,分别用作两个地理信息的角色扮演维度。
  • 把数据备份表sales_order_fact_bak中的数据装载回销售订单事实表,同时需要关联两个邮编角色维度视图,查询出两个代理键,装载到事实表中。注意老的事实表与新的邮编维度表是通过客户维度表关联起来的,所以在子查询中需要三表连接,然后用两个左外连接查询出所有原事实表数据,装载到新的增加了邮编维度代理键的事实表中。
  • 在customer_dim表上删除列时,需要使用cascade子句同时删除依赖它的视图,之后重建相关视图。

二、修改定期数据装载函数

定期装载函数有三个地方的修改:

  • 删除客户维度装载里所有邮编信息相关的列,因为客户维度里不再有客户邮编和送货邮编相关信息。
  • 在事实表中引用客户邮编视图和送货邮编视图中的代理键。
  • 修改pa_customer_dim装载,因为需要从销售订单事实表的customer_zip_code_sk获取客户邮编。

修改后的fn_regular_load函数如下。

  1. create or replace function fn_regular_load ()
  2. returns void as
  3. $$
  4. declare
  5. -- 设置scd的生效时间
  6. v_cur_date date := current_date;
  7. v_pre_date date := current_date - 1;
  8. v_last_load date;
  9. begin
  10. -- 分析外部表
  11. analyze ext.customer;
  12. analyze ext.product;
  13. analyze ext.sales_order;
  14.  
  15. -- 将外部表数据装载到原始数据表
  16. truncate table rds.customer;
  17. truncate table rds.product;
  18.  
  19. insert into rds.customer select * from ext.customer;
  20. insert into rds.product select * from ext.product;
  21. insert into rds.sales_order
  22. select order_number,
  23. customer_number,
  24. product_code,
  25. order_date,
  26. entry_date,
  27. order_amount,
  28. order_quantity,
  29. request_delivery_date,
  30. verification_ind,
  31. credit_check_flag,
  32. new_customer_ind,
  33. web_order_flag
  34. from ext.sales_order;
  35.  
  36. -- 分析rds模式的表
  37. analyze rds.customer;
  38. analyze rds.product;
  39. analyze rds.sales_order;
  40.  
  41. -- 设置cdc的上限时间
  42. select last_load into v_last_load from rds.cdc_time;
  43. truncate table rds.cdc_time;
  44. insert into rds.cdc_time select v_last_load, v_cur_date;
  45.  
  46. -- 装载客户维度
  47. insert into tds.customer_dim
  48. (customer_number,
  49. customer_name,
  50. customer_street_address,
  51. shipping_address,
  52. isdelete,
  53. version,
  54. effective_date)
  55. select case flag
  56. when 'D' then a_customer_number
  57. else b_customer_number
  58. end customer_number,
  59. case flag
  60. when 'D' then a_customer_name
  61. else b_customer_name
  62. end customer_name,
  63. case flag
  64. when 'D' then a_customer_street_address
  65. else b_customer_street_address
  66. end customer_street_address,
  67. case flag
  68. when 'D' then a_shipping_address
  69. else b_shipping_address
  70. end shipping_address,
  71. case flag
  72. when 'D' then true
  73. else false
  74. end isdelete,
  75. case flag
  76. when 'D' then a_version
  77. when 'I' then 1
  78. else a_version + 1
  79. end v,
  80. v_pre_date
  81. from (select a.customer_number a_customer_number,
  82. a.customer_name a_customer_name,
  83. a.customer_street_address a_customer_street_address,
  84. a.shipping_address a_shipping_address,
  85. a.version a_version,
  86. b.customer_number b_customer_number,
  87. b.customer_name b_customer_name,
  88. b.customer_street_address b_customer_street_address,
  89. b.shipping_address b_shipping_address,
  90. case when a.customer_number is null then 'I'
  91. when b.customer_number is null then 'D'
  92. else 'U'
  93. end flag
  94. from v_customer_dim_latest a
  95. full join rds.customer b on a.customer_number = b.customer_number
  96. where a.customer_number is null -- 新增
  97. or b.customer_number is null -- 删除
  98. or (a.customer_number = b.customer_number
  99. and not
  100. (coalesce(a.customer_name,'') = coalesce(b.customer_name,'')
  101. and coalesce(a.customer_street_address,'') = coalesce(b.customer_street_address,'')
  102. and coalesce(a.shipping_address,'') = coalesce(b.shipping_address,'')
  103. ))) t
  104. order by coalesce(a_customer_number, 999999999999), b_customer_number limit 999999999999;
  105.  
  106. -- 装载产品维度
  107. insert into tds.product_dim
  108. (product_code,
  109. product_name,
  110. product_category,
  111. isdelete,
  112. version,
  113. effective_date)
  114. select case flag
  115. when 'D' then a_product_code
  116. else b_product_code
  117. end product_code,
  118. case flag
  119. when 'D' then a_product_name
  120. else b_product_name
  121. end product_name,
  122. case flag
  123. when 'D' then a_product_category
  124. else b_product_category
  125. end product_category,
  126. case flag
  127. when 'D' then true
  128. else false
  129. end isdelete,
  130. case flag
  131. when 'D' then a_version
  132. when 'I' then 1
  133. else a_version + 1
  134. end v,
  135. v_pre_date
  136. from (select a.product_code a_product_code,
  137. a.product_name a_product_name,
  138. a.product_category a_product_category,
  139. a.version a_version,
  140. b.product_code b_product_code,
  141. b.product_name b_product_name,
  142. b.product_category b_product_category,
  143. case when a.product_code is null then 'I'
  144. when b.product_code is null then 'D'
  145. else 'U'
  146. end flag
  147. from v_product_dim_latest a
  148. full join rds.product b on a.product_code = b.product_code
  149. where a.product_code is null -- 新增
  150. or b.product_code is null -- 删除
  151. or (a.product_code = b.product_code
  152. and not
  153. (a.product_name = b.product_name
  154. and a.product_category = b.product_category))) t
  155. order by coalesce(a_product_code, 999999999999), b_product_code limit 999999999999;
  156.  
  157. -- 装载销售订单事实表
  158. insert into sales_order_fact
  159. select a.order_number,
  160. customer_sk,
  161. product_sk,
  162. e.date_sk,
  163. e.year * 100 + e.month,
  164. order_amount,
  165. order_quantity,
  166. f.date_sk,
  167. g.sales_order_attribute_sk,
  168. h.customer_zip_code_sk,
  169. i.shipping_zip_code_sk
  170. from rds.sales_order a,
  171. v_customer_dim_his c,
  172. v_product_dim_his d,
  173. date_dim e,
  174. date_dim f,
  175. sales_order_attribute_dim g,
  176. v_customer_zip_code_dim h,
  177. v_shipping_zip_code_dim i,
  178. rds.customer j,
  179. rds.cdc_time k
  180. where a.customer_number = c.customer_number
  181. and a.order_date >= c.effective_date
  182. and a.order_date < c.expiry_date
  183. and a.product_code = d.product_code
  184. and a.order_date >= d.effective_date
  185. and a.order_date < d.expiry_date
  186. and date(a.order_date) = e.date
  187. and date(a.request_delivery_date) = f.date
  188. and a.verification_ind = g.verification_ind
  189. and a.credit_check_flag = g.credit_check_flag
  190. and a.new_customer_ind = g.new_customer_ind
  191. and a.web_order_flag = g.web_order_flag
  192. and a.customer_number = j.customer_number
  193. and j.customer_zip_code = h.customer_zip_code
  194. and j.shipping_zip_code = i.shipping_zip_code
  195. and a.entry_date >= k.last_load and a.entry_date < k.current_load;
  196.  
  197. -- 重载PA客户维度
  198. truncate table pa_customer_dim;
  199. insert into pa_customer_dim
  200. select distinct a.*
  201. from customer_dim a,
  202. sales_order_fact b,
  203. v_customer_zip_code_dim c
  204. where c.customer_state = 'pa'
  205. and b.customer_zip_code_sk = c.customer_zip_code_sk
  206. and a.customer_sk = b.customer_sk;
  207.  
  208. -- 分析tds模式的表
  209. analyze customer_dim;
  210. analyze product_dim;
  211. analyze sales_order_fact;
  212. analyze pa_customer_dim;
  213.  
  214. -- 更新时间戳表的last_load字段
  215. truncate table rds.cdc_time;
  216. insert into rds.cdc_time select v_cur_date, v_cur_date;
  217.  
  218. end;
  219. $$
  220. language plpgsql;

上面的函数需要注意两个地方。装载事实表数据时,除了关联两个邮编维度视图外,还要关联过渡区的rds.customer表。这是因为要取得邮编维度代理键,必须连接邮编代码字段,而邮编代码已经从客户维度表中删除,只有在源数据的客户表中保留。第二个改变是PA子维度的装载。州代码已经从客户维度表删除,被放到了新的邮编维度表中,而客户维度和邮编维度并没有直接关系,它们是通过事实表的客户代理键和邮编代理键产生联系,因此必须关联事实表、客户维度表、邮编维度表三个表才能取出PA子维度数据。这也就是把PA子维度的装载放到了事实表装载之后的原因。

三、测试

按照以下步骤测试修改后的定期装载脚本。

  1. 对源数据的客户邮编相关信息做一些修改。
  2. 装载新的客户数据前,查询最后的客户和送货邮编,后面可以用改变后的信息和此查询的输出作对比。
  3. 新增销售订单源数据。
  4. 执行定期装载。
  5. 查询客户维度表、售订单事实表和PA子维度表,确认数据已经正确装载。

执行下面的语句,对源数据的客户信息做以下两处修改:客户编号4的客户和送货邮编信息;新增一个编号15的客户。

  1. update source.customer
  2. set customer_street_address = '9999 louise dr.',
  3. customer_zip_code = 17055,
  4. customer_city = 'pittsburgh',
  5. shipping_address = '9999 louise dr.',
  6. shipping_zip_code = 17055,
  7. shipping_city = 'pittsburgh'
  8. where customer_number = 4;
  9.  
  10. insert into source.customer
  11. values(15, 'super stores', '1000 woodland st.', 17055, 'pittsburgh', 'pa', '1000 woodland st.', 17055, 'pittsburgh', 'pa');
  12.  
  13. commit;

现在在装载新的客户数据前查询最后的客户和送货邮编。后面可以用改变后的信息和此查询的输出作对比。查询语句如下。

  1. select order_date_sk odsk,
  2. customer_number cn,
  3. customer_zip_code czc,
  4. shipping_zip_code szc
  5. from v_customer_zip_code_dim a,
  6. v_shipping_zip_code_dim b,
  7. sales_order_fact c,
  8. customer_dim d
  9. where a.customer_zip_code_sk = c.customer_zip_code_sk
  10. and b.shipping_zip_code_sk = c.shipping_zip_code_sk
  11. and d.customer_sk = c.customer_sk;
  12. order by odsk;

然后使用下面的语句新增两条销售订单。

  1. set @order_date := from_unixtime(unix_timestamp('2017-05-30 00:00:01') + rand() * (unix_timestamp('2017-05-30 12:00:00') - unix_timestamp('2017-05-30 00:00:01')));
  2. set @request_delivery_date := from_unixtime(unix_timestamp(date_add(current_date, interval 5 day)) + rand() * 86400);
  3. set @amount := floor(1000 + rand() * 9000);
  4. set @quantity := floor(10 + rand() * 90);
  5.  
  6. insert into source.sales_order values
  7. (null, 4, 3, 'y', 'y', 'y', 'n', @order_date, @request_delivery_date,
  8. @order_date, @amount, @quantity);
  9.  
  10. set @order_date := from_unixtime(unix_timestamp('2017-05-30 12:00:00') + rand() * (unix_timestamp('2017-05-31 00:00:00') - unix_timestamp('2017-05-30 12:00:00')));
  11. set @request_delivery_date := from_unixtime(unix_timestamp(date_add(current_date, interval 5 day)) + rand() * 86400);
  12. set @amount := floor(1000 + rand() * 9000);
  13. set @quantity := floor(10 + rand() * 90);
  14.  
  15. insert into source.sales_order values
  16. (null, 15, 4, 'y', 'n', 'y', 'n', @order_date, @request_delivery_date,
  17. @order_date, @amount, @quantity);
  18.  
  19. commit;

执行下面的命令定期装载。

  1. ~/regular_etl.sh

查询customer_dim表,确认两个改变的客户,即编号4和15的客户,已经正确装载。

  1. select customer_sk csk,
  2. customer_number cnum,
  3. customer_name cnam,
  4. customer_street_address csd,
  5. shipping_address sd,
  6. version,
  7. effective_date,
  8. expiry_date
  9. from v_customer_dim_his
  10. where customer_number in (4, 15);

查询结果如图2所示。

图2

查询sales_order_fact表里的两条新销售订单,确认邮编已经正确装载。

  1. select a.order_number onum,
  2. e.customer_number cnum,
  3. b.customer_zip_code czc,
  4. c.shipping_zip_code szc,
  5. f.product_code pc,
  6. d.order_date od,
  7. a.order_amount,
  8. a.order_quantity
  9. from sales_order_fact a,
  10. v_customer_zip_code_dim b,
  11. v_shipping_zip_code_dim c,
  12. v_order_date_dim d,
  13. customer_dim e,
  14. product_dim f
  15. where a.customer_sk = e.customer_sk
  16. and a.product_sk = f.product_sk
  17. and a.customer_zip_code_sk = b.customer_zip_code_sk
  18. and a.shipping_zip_code_sk = c.shipping_zip_code_sk
  19. and a.order_date_sk = d.order_date_sk
  20. order by a.order_number desc
  21. limit 2;

查询结果如图3所示。

图3

查询v_pa_customer_dim_his视图,确认PA客户正确装载。

  1. select customer_sk csk,
  2. customer_number cnum,
  3. customer_name cnam,
  4. customer_street_address csa,
  5. shipping_address sad,
  6. version,
  7. effective_date,
  8. expiry_date
  9. from v_pa_customer_dim_his
  10. order by customer_sk;

查询结果如图4所示。

图4

HAWQ取代传统数仓实践(十一)——维度表技术之维度合并的更多相关文章

  1. HAWQ取代传统数仓实践(十八)——层次维度

    一.层次维度简介 大多数维度都具有一个或多个层次.例如,示例数据仓库中的日期维度就有一个四级层次:年.季度.月和日.这些级别用date_dim表里的列表示.日期维度是一个单路径层次,因为除了年-季度- ...

  2. HAWQ取代传统数仓实践(十九)——OLAP

    一.OLAP简介 1. 概念 OLAP是英文是On-Line Analytical Processing的缩写,意为联机分析处理.此概念最早由关系数据库之父E.F.Codd于1993年提出.OLAP允 ...

  3. HAWQ取代传统数仓实践(十六)——事实表技术之迟到的事实

    一.迟到的事实简介 数据仓库通常建立于一种理想的假设情况下,这就是数据仓库的度量(事实记录)与度量的环境(维度记录)同时出现在数据仓库中.当同时拥有事实记录和正确的当前维度行时,就能够从容地首先维护维 ...

  4. HAWQ取代传统数仓实践(十三)——事实表技术之周期快照

    一.周期快照简介 周期快照事实表中的每行汇总了发生在某一标准周期,如一天.一周或一月的多个度量.其粒度是周期性的时间段,而不是单个事务.周期快照事实表通常包含许多数据的总计,因为任何与事实表时间范围一 ...

  5. HAWQ取代传统数仓实践(十)——维度表技术之杂项维度

    一.什么是杂项维度 简单地说,杂项维度就是一种包含的数据具有很少可能值的维度.事务型商业过程通常产生一系列混杂的.低基数的标志位或状态信息.与其为每个标志或属性定义不同的维度,不如建立单独的将不同维度 ...

  6. HAWQ取代传统数仓实践(七)——维度表技术之维度子集

    有些需求不需要最细节的数据.例如更想要某个月的销售汇总,而不是某天的数据.再比如相对于全部的销售数据,可能对某些特定状态的数据更感兴趣等.此时事实数据需要关联到特定的维度,这些特定维度包含在从细节维度 ...

  7. HAWQ取代传统数仓实践(十二)——维度表技术之分段维度

    一.分段维度简介 在客户维度中,最具有分析价值的属性就是各种分类,这些属性的变化范围比较大.对某个个体客户来说,可能的分类属性包括:性别.年龄.民族.职业.收入和状态,例如,新客户.活跃客户.不活跃客 ...

  8. HAWQ取代传统数仓实践(十五)——事实表技术之无事实的事实表

    一.无事实事实表简介 在多维数据仓库建模中,有一种事实表叫做"无事实的事实表".普通事实表中,通常会保存若干维度外键和多个数字型度量,度量是事实表的关键所在.然而在无事实的事实表中 ...

  9. HAWQ取代传统数仓实践(八)——维度表技术之角色扮演维度

    单个物理维度可以被事实表多次引用,每个引用连接逻辑上存在差异的角色维度.例如,事实表可以有多个日期,每个日期通过外键引用不同的日期维度,原则上每个外键表示不同的日期维度视图,这样引用具有不同的含义.这 ...

随机推荐

  1. beego——表单验证

    表单验证是用于数据验证和错误收集的模块. 安装: go get github.com/astaxie/beego/validation 测试: go test github.com/astaxie/b ...

  2. HTML,CSS,Javascript,JQuery

    HTML 一套浏览器认识的规则 标签 1.<head></head> 2.<title></title> 3.<body></body ...

  3. django联合查询

    假设A表的主键aid作为B表的外键,A表有属性name,那么想查询B表中name为abc的元素就可以这样写: B.objects.all().filter(aid__name = 'abc') __真 ...

  4. linux 查看tomcat 日志

    tomcat 重启: cd /opt/appserver/apache-tomcat-/bin ./shutdown.sh -ef|grep tomcat kill - ./startup.sh 查看 ...

  5. c9.io

    老常时间没写了,这次是真碰到心动的东西了,赶快给大家奉献上来. (先上图!) (Cloud9 IDE,云端IDE,简单一点就是运行在浏览器中的IDE,你不需要安装任何东西, 只要打开任何一个浏览器,甚 ...

  6. ASP.NET MVC CheckBoxFor的int to bool

    当我们使用CheckBoxFor类型需要使用bool ,可以将 int转换成bool <div class="form-group"> <label class= ...

  7. C\C++与Java中的static关键字

    C\C++里面的static: 面向过程的static: 在c和c++面向过程的设计里,在全局变量前加上static关键字则可将该变量定义为一个静态全局变量,比如: static int a; 那么c ...

  8. 黑苹果Yosemite 10.10.1懒人版完美安装及简单驱动设置

    1.硬件概要 CPU: 英特尔 Xeon E3-1230 V2 (四核)主板: 技嘉 H77-DS3H (Intel H77 (Panther Point Base))内存: 8 GBytes显卡: ...

  9. hydra简单使用示例

    本内容为网上收集整理,仅作为备忘!! hydra简单使用示例: 破解https: # hydra -m /index.php -l muts -P pass.txt 10.36.16.18 https ...

  10. 重装window 7系统,从做一个u盘启动盘,到装系统,很不错

    老毛桃U盘启动盘制作工具是现在最流行的U盘装系统和维护电脑的专用工具,一是制作简单,几乎100%支持所有U盘一键制作为启动盘,不必顾虑以前量产U盘考虑专用工具的问题.二是制作后工具功能强大,支持GHO ...