Checks whether a specified table exists.
Syntax
boolean table_exists(string <table_name>)
Parameters
table_name: required. The name of the table, which is of the STRING type. You can specify a project name in the table name. The name of a table can be my_proj.my_table
. If you do not specify a project name, the current project name is used.
Return value
A value of the BOOLEAN type is returned. If the specified table exists, True is returned. Otherwise, False is returned.
Examples
-- Use this function for the list in the SELECT statement.
select if(table_exists('abd'), col1, col2) from src;
Related functions
For more information, see Other functions.