Sql server
1. Determine whether the table users existif object_id(N'Users'N'U') is not NULL Print 'exist'Else Print 'does not exist' 2. Determine if the Name column exists in the table usersif exists(Select * fromsyscolumnswhereId=object_id('Users') andName='Name'collate Chinese_prc_ci_ai_ws)Print 'exist'Else Print 'does not exist'Note: Collate chinese_prc_ci_ai_ws represents case-insensitive
Oracle
1. Judging whether the table is a villageDeclare --here is the local variableIinteger;begin --here is the test statement Select Count(1) intoI fromAll_tableswheretable_name='Site_info' andOwner='WIFI'; if(I>0) ThenDbms_output.put_line ('exist'); ElseDbms_output.put_line ('does not exist'); End if;End;2. Determine if a column existsDeclare --here is the local variableIinteger;begin --here is the test statement Select Count(1) intoI fromAll_tab_columnswhereOwner='WIFI' andtable_name='Site_info' andcolumn_name='site_id'; if(I>0) ThenDbms_output.put_line ('exist'); ElseDbms_output.put_line ('does not exist'); End if;End;
Description: PL/SQL needs to create a new test window to run the above statement
SQL Server and Oracle determine if tables and columns exist