-1

I have created a table using sqlplus without any data. How can I write a test in DBFit to check if a table with that name exists?

APC
  • 144,005
  • 19
  • 170
  • 281

3 Answers3

1

you can use Query Stats for this.

syntax is like this.

!| Query  Stats |  
|   query     |    is empty?|

|select * from user_tables where table_name = 'table_name'         |false          |
Niraj Sonawane
  • 10,225
  • 10
  • 75
  • 104
0

So you want an assertion that the table exists. Simply a matter of checking of the Oracle data dictionary.

Without knowing DBfit syntax the query would be:

select count(*) 
from user_tables
where table_name = 'YOUR_TEST_TABLE';

If that returns 1 the table exists with that name. If 0 it doesn't.

APC
  • 144,005
  • 19
  • 170
  • 281
0

Following the answer from APC, in DBFIt you would do something like this:

!|Query| !- select count(*) KNT
from user_tables
where table_name = 'YOUR_TEST_TABLE' -!|
|KNT|
|1|

Although, if its not a table of your creation, you may wish to use all_tables instead of user_tables.

Joe C
  • 1
  • 1
  • Welcome to StackOverflow: if you post code, XML or data samples, please highlight those lines in the text editor and click on the "code samples" button ( { } ) on the editor toolbar or using Ctrl+K on your keyboard to nicely format and syntax highlight it! – WhatsThePoint Feb 09 '18 at 11:31