How to check if a table exists in a given schema

0 votes
Sep 27, 2019 in Database by Omaiz
• 560 points
1,739 views

1 answer to this question.

0 votes

Since you havent mentioned the DBMS in which you are facing the issue, I have assumed it to be POSTGRES

SELECT to_regclass('foo');

In Postgres 9.3 or older use a cast to regclass:

SELECT 'foo'::regclass;

If at all your requirement is MYSql then use the below statement:

You can use show tables like this to see if a single table exists:

mysql> show tables like "test1";
answered Oct 4, 2019 by Daric
• 500 points

Related Questions In Database

0 votes
2 answers

How to select the nth row in a SQL database table?

SELECT * FROM ( SELECT ID, NAME, ROW_NUMBER() ...READ MORE

answered Apr 23, 2020 in Database by anand
• 140 points
13,191 views
0 votes
1 answer

How to do a batch insert in MySQL

You can try out the following query: INSERT ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,380 points
1,533 views
0 votes
2 answers

What are the ways to get the count of records in a table

With the help of the SQL count ...READ MORE

answered Aug 20, 2020 in Database by Okugbe
• 280 points
1,481 views
0 votes
1 answer

How to cache data in a MVC application?

Reference the System.Web dll in your model ...READ MORE

answered Oct 25, 2018 in Database by Frankie
• 9,810 points
804 views
0 votes
1 answer

How to display the queries executed by a particular user in MySQL?

From the version 5.1.7 onward, MySQL allows ...READ MORE

answered Mar 7, 2019 in Database by Mishti
• 480 points
1,025 views
0 votes
2 answers
0 votes
1 answer

How can I check my all existing table in MySQL database?

Hi Pratik, I understand your problem regarding this ...READ MORE

answered Jul 1, 2019 in Database by sampriti
• 1,120 points
500 views
0 votes
1 answer

How to load data of .csv file in MySQL Database Table?

At first, put the dataset in the ...READ MORE

answered Jul 5, 2019 in Database by Reshma
600 views
0 votes
1 answer

MySQL query finding values in a comma separated string

To find MySQL query values in a comma-separated ...READ MORE

answered Oct 4, 2019 in Database by Daric
• 500 points
1,250 views
0 votes
1 answer

Can we store images in database

Beware that serving images from DB is ...READ MORE

answered Oct 4, 2019 in Database by Daric
• 500 points
169 views