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?
Asked
Active
Viewed 226 times
-1
-
I do not know what dbfit is. A quick google tell me it's a testing too. So what aspect of your table do you want to check? – BobC Feb 28 '17 at 10:15
-
DbFit is a unit testing tool . I'm are checking queries like select * from using dbfit . now, i want to check create table in dbFit – munjuluri vaibhav Feb 28 '17 at 10:19
-
Ok, so you created you table in sqlplus. What are you now checking? That it exists? That's it has the right name? That it's empty? – BobC Feb 28 '17 at 10:24
-
checking if the table exists with that name – munjuluri vaibhav Feb 28 '17 at 10:37
3 Answers
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