If an SQL data table exists, delete it and create it if it does not exist.
Our commonly used mssql server
Stored Procedure:
Set @ sign = 0;
Select 1 into @ sign from information_schema
Where table_name = 'a' and table_schema = 'tutorial name of the database in which table aa is located ';
If @ sign = 0 then
Create table aa .....
End if;
Command line:
Create table if not exists aa (
Table definition
);
There is no such thing as SQL Server in ORACLE.
If exists (select * from dbo. sysobjects where id = object_id (n' [dbo]. [HY_BSCDNM_J] ') and OBJECTPROPERTY (id, n' isusertable') = 1)
Drop table [dbo]. [HY_BSCDNM_J]
GO
Create table .......
To avoid the need to always click SURE, you can refer to the online method to save the trouble of clicking when creating a temporary table.
The script to be collected is completely written, and one-step execution is in place to export the waiting results, saving a lot of time to complete the next Request.
Declare
I integer;
Begin
Select count (*) into I from user_tables where table_name = 'xb _ test001 ';
If I> 0 then
Dbms_output.put_line ('This table already exists! ');
Execute immediate 'drop TABLE xb_test001 ';
Else
Dbms_output.put_line ('This table does not exist ');
End if;
Execute immediate 'create TABLE XB_TEST001 (id int primary key, name varchar (50 ))';
End;
Data is updated when stored
The SQL execution requires three steps:
$ SQL = "if (select * from ips tutorial tats where ip = '2017. 168.0.1 '){
Update ipstats set clicks = clicks + 1 where ip = '192. 168.0.1 ';
} Else {
Insert into ipstats (ip, clicks) values ('192. 168.0.1 ', 1 );
}";
Mysql tutorial _ query ($ SQL );
For more details, see: http://www.111cn.net/database/mysql/33922.htm