Check whether the table exists
1. Use System View: SYS. Tables
Select name from SYS. tables where name = 'tablaname' and type = 'U'
Type = 'U' is used to exclude stored procedures, views, and system tables. It refers to the user table user_table.
2. Use the System View: sysobjects
Select * From sysobjects where id = object_id ('usersubsyscenthistory _ null') and xtype = 'U'
Xtype = 'U' is used to exclude stored procedures, views, and system tables. It refers to the user table user_table.
Determine whether a Column exists
1. Assume that the table is AAA and the field to be added is the name field.
Select * From syscolumns where [name] = 'name' and objectproperty (ID, 'isusertable') = 1 and object_name (ID) = 'aaa ')
Bytes -------------------------------------------------------------------------------------------------------------------------------
Note;
Entitymanager em = super. getentitymanager (appconfig. persistence_cent );
Object result = em. createnativequery (SQL). getsingleresult ();
Getsingleresult ()
Throws:
NoResultException
-If there is no result: the returned value is 0.
NonUniqueResultException
-If more than one result: one additional result is returned.
Therefore, ensure that there is only one record. You can use list instead.Getresultlist(), Determine whether there is a result by judging its size.