2 Replies - 4822 Views - Last Post: 11 February 2008 - 12:59 PM Rate Topic: -----

#1 bent27  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-February 08

check if table is empty and then alter it

Posted 11 February 2008 - 12:05 PM

I have an existing database....this has to be upgraded with a new set of tables in addition to the existing ones. Some of the existing tables have to be modified. I'm writing an alter for this.

There is a table STDM_T, I know when I'm running these alters this table will most likely be empty, but I have to check to make sure the table is empty and if it is, I have to drop the table and recreate it!!

This is supposed to go into 'alters'... Any help is appreciated!!

TIA

Is This A Good Question/Topic? 0
  • +

Replies To: check if table is empty and then alter it

#2 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: check if table is empty and then alter it

Posted 11 February 2008 - 12:12 PM

You might want to try running a simple query to make sure it's empty - something like SELECT COUNT(*).
Was This Post Helpful? 0
  • +
  • -

#3 bent27  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-February 08

Re: check if table is empty and then alter it

Posted 11 February 2008 - 12:59 PM

well, I have the following:

select count(*) into v_count from table
where rownum=1

if(v_count>0) then

create table
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1