Search code examples
sqloracle-databasedatabase-partitioning

How can I write a query for Partitioned SQL tables?


Here is my Create tabled and partition query: How can I insert Data into my Partitioned tables? AND How can I make a select statement that displays ROWID , ID, TITLE, PUBID and PUBDATE for all rows of data in my lab6_zl table I created.

create table lab6_zl (
ID number not null, 
TITLE varchar2(40), 
PUBID char(3), 
PUBDATE date,
constraint lab6_pk primary key(ID))
Partition by range (pubdate)
(
Partition p1 values less than (to_date('01-JAN-2000','DD-MON-YYYY')),
Partition p2 values less than (to_date('01-JAN-2010','DD-MON-YYYY')),
Partition p3 values less than (MAXVALUE)
)

Solution

  • You would insert and select data just the same way that you would for a non-partitioned table

    INSERT INTO lab6_z1( id, title, pubid, pubdate )
      VALUES( 1, 'Something', 'FOO', sysdate );
    
    SELECT rowid,
           id,
           title,
           pubid,
           pubdat
      FROM lab6_z1;