-
Hi, all
I have a situation here, I have a table called messagearchive,which grows too big too fast,
SQL> desc messagearchive;
Name Null? Type
----------------------------------------- -------- ----------------------------
MSGID NOT NULL CHAR(16)
SERVICEID NOT NULL CHAR(16)
MSGTEXT VARCHAR2(4000)
MSGDATE NOT NULL DATE
based on our business requirements, we only need to keep two(latest) msgtexts for each serviceid. I can do it in a very clumsy way, which is that I do a
select unique(serviceid),max(msgdate) from messagearchive; and put it into a temp table, and get results by joining messagearchive and temp and put it into temp_messagearchive table and then truncate table messagearchive and put back the data from temp_messagearchive to messagearchive.
I know there must be a better way to do it, but I just can not come up with it. I would appreciate if anyone can help me out with PL/SQL packages to do the same job. Thanks for help.
Dragon
-
Sorry, should be
select unique(serviceid),max(msgdate) from messagearchive group by serviceid;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|