MODEL Clause

Setup

Run the code on this page in SQL*Plus to create the sample tables, data, etc. used by the examples in this section.

Be sure to read Using SQL Snippets ™ before executing any of these setup steps.

create table t
(
  key        number(3)    ,
  key_2      varchar2(5)  ,
  group_1    varchar2(7)  ,
  group_2    varchar2(7)  ,
  date_val   date         ,
  num_val    number
);

insert into t values ( 1 , 'T-1' , 'A' , 'a1' , date '2005-01-01', 100  );
insert into t values ( 2 , 'T-2' , 'A' , 'a2' , date '2005-06-12', 200  );
insert into t values ( 3 , 'T-3' , 'A' , 'a3' , null             , 300  );
insert into t values ( 4 , 'T-4' , 'B' , 'a1' , date '2006-02-01', null );
insert into t values ( 5 , 'T-5' , 'B' , 'a2' , date '2006-06-12', 300  );
insert into t values ( 6 , 'T-6' , 'B' , 'a3' , date '2005-01-01', 100  );
insert into t values ( 7 , 'T-7' , 'C' , 'a1' , date '2006-06-12', 100  );
insert into t values ( 8 , 'T-8' , 'C' , 'a2' , null             , null );
insert into t values ( 9 , 'T-9' , null, 'a1' , date '2005-02-01', 200  );
insert into t values ( 10, 'T-10', null, 'a2' , date '2005-02-01', 800  );

commit;

column group_1 format a10
column group_2 format a10
column num_val format 999999

create table t2
(
  key  number(3)
);

insert into t2 values ( 2 );
insert into t2 values ( 4 );
insert into t2 values ( 6 );


create table t3
(
  key  varchar2(10) ,
  name varchar2(15)
);

insert into t3 values ( 'a1', 'Alpha Squad 1' );
insert into t3 values ( 'a2', 'Alpha Squad 2' );
insert into t3 values ( 'a3', 'Alpha Squad 3' );

commit;


column key              format 99999
column new_text_measure format a20

column flag              format a4
column using_any         format a9
column using_is_any      format a12
column using_null        format a10
column using_is_null     format a13
column using_equals_null format a17

 



Linking to SQL Snippets ™

To link to this page in Oracle Technology Network Forums or OraFAQ Forums cut and paste this code.

  • [url=http://www.sqlsnippets.com/en/topic-11678.html]SQL Snippets: MODEL Clause - Setup[/url]

To link to this page in HTML documents or Blogger comments cut and paste this code.

  • <a href="http://www.sqlsnippets.com/en/topic-11678.html">SQL Snippets: MODEL Clause - Setup</a>

To link to this page in other web sites use the following values.

  • Link Text : SQL Snippets: MODEL Clause - Setup
  • URL (href): http://www.sqlsnippets.com/en/topic-11678.html