简体   繁体   中英

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)
)

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;

You can take it as a plain table, whenever selecting, inserting, updating, and deleting. Most of the time, you just need to care about one thing, add the partition condition(in this case, "PUBDATE") as much as possible, or it will cost more than plain table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM