How to check if a table exists in a given schema

0 votes
Sep 27, 2019 in Database by Omaiz
• 560 points
2,706 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
26,258 views
0 votes
1 answer

How to rename a column in a database table using SQL?

For SQL Server, use sp_rename USE AdventureWorks; GO EXEC sp_rename 'Customers.CustomerTerritory.TerritoryID', ...READ MORE

answered Feb 9, 2022 in Database by Neha
• 9,020 points
758 views
0 votes
0 answers

How to split a string of text in excel based on a given word?

I have a list of combinations of ...READ MORE

Apr 4, 2022 in Database by gaurav
• 23,260 points
444 views
0 votes
1 answer

EXCEL How to check if Column A contains specific value and Column B contains 2 specific values?

If you're looking for the string CHECK in cells ...READ MORE

answered Apr 6, 2022 in Database by gaurav
• 23,260 points
635 views
0 votes
0 answers

How to find sum of multiple columns in a table in SQL Server 2005?

I have a table Emp which has these rows: Emp_cd ...READ MORE

Aug 19, 2022 in Database by Kithuzzz
• 38,000 points
1,615 views
0 votes
0 answers

Check if table exists in SQL Server

I want this to be the last ...READ MORE

Aug 21, 2022 in Database by Kithuzzz
• 38,000 points
38,074 views
0 votes
0 answers

How to select the last record of a table in SQL?

Here is an example of code that ...READ MORE

Aug 23, 2022 in Database by Kithuzzz
• 38,000 points
1,084 views
0 votes
0 answers

How to create a table from select query result in SQL Server 2008

I tried to build a table from ...READ MORE

Sep 2, 2022 in Database by Kithuzzz
• 38,000 points
853 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
3,177 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
956 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP