Ads were blocked by your webbrowser.

This is not a problem, but keep in mind that developing HeidiSQL, user support and hosting takes time and money.

You may want to send a donation instead.

Create view if a table exists

SurSild's profile image SurSild posted 4 weeks ago in General

Hi,

So I want to write a procedure to create a view, but only if a certain table exists. If it doesn't exist I don't want it to do anything. So something like this:

If table_X exists THEN CREATE VIEW table_X_view AS SELECT distance_start10 as distance_km, distance_end10 as distance_end_km FROM table_X

I've tried many different possibilities, but I just can't figure it out.

ansgar's profile image ansgar posted 4 weeks ago

Which server is it? And probably also mention the version.

SurSild's profile image SurSild posted 4 weeks ago

I use MySQL, and am using Heidi SQL version 10.2.0.5599. If this didn't answear your question, please give me more info about how to answer you as I am not that good with these technical stuff.

ansgar's profile image ansgar posted 4 weeks ago

There are a couple of ways to check if a table exist:

https://www.electrictoolbox.com/check-if-mysql-table-exists/

Please login to leave a reply, or register at first.