Technorati label: before creating a table in PL/SQL, determine whether the table exists.
Delete the execution statement of the table if any.
Since PL/SQL is used for Oracle client operations, since
Query whether a table exists:In practice, you may need to delete a table. before deleting a table, you are advised to check whether the table exists to prevent returning error messages. In SQL
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: sysobjectsSelect * From sysobjects where id = obj
Drop table # tempcitys
Select * into # tempcitys from hy_citys
When the preceding statement is run for the first time, it must have encountered an error, but it will not be used for the second time.Because select * into # tempcitys from hy_citys automatically creates a temporary table # tempcitys, the first temporary table does not exist, and a drop
a view
DROP VIEW [dbo].[View name]
GO
---------------
--determine if the name of the function to be created exists
IF exists(SELECT * fromDbo.sysobjectsWHEREId= object_id(N'[dbo]. [function name]') andXtypeinch(N'FN'N'IF'N'TF'))
--Delete a function
DROP FUNCTION [dbo].[Name of function]
GO
IF col_length('Table name','Column Name') is NULL
PRINT 'does not exist
MySQL: Error: Tablespace for table 'database'. 'temp ''exists. Please DISCARD the tablespace before IMPORT. Solution: createtablespace
Today, when I operate mysql database tables on navicat, I suddenly fail to respond. Then restart the mysql service. Then start the service and check the
Tags: ar for file data SP C R EF BSToday, working on the MySQL database table on Navicat, suddenly no response. The MySQL service is also terminated after the restart. Then start the service, check the table, find a table card is gone, add a table again. Reported a mistake:E
. TempTable to name it, the table can persist until the database is restarted. 2. Manually delete the drop table Temptablename Description: The drop TABLE statement explicitly drops the temporary table, otherwise the temporary table will be automatically dropped by the syste
Check whether the Access Table exists
String SQL = "select count (*) from msysobjects where name = 'user table '";
How to Set access permission to access the msysobjects system table
How to Set access permission to access the m
When IDENTITY_INSERT is set to OFF, you cannot insert an explicit value into the identity column in table ' #TT '.I was in SQL Server to write the stored procedure encountered this error, then thought: how the temporary table has a primary key, I also did not set the primary key.Then I worked with my colleagues to debug, and finally found out. The reason is that
created and destroyed when desired.Applicable situation:Table variable: If it is a small amount of data, then use a table variable. The cost of using table variables is less than temporary tables. Where the actual project is used, such as bulk deletion, you need to pass multiple IDs as parameters, some people will splice the ID string and then parse it in the database; My approach is usually to pass the XM
table, if any, set the out parameter to 1 * After the connection is disconnected, the global temp table is automatically reclaimed by SQL Server * In the event of an accident such as a power outage, the global temp table still
. Especially in some data warehouse mining systems, SQL statement structure and nested structure are very complex. With AS can help us simplify the sentence structure, improve the readability of the statement, and also improve the control of the statement execution plan.Oracle 9i New with syntax, you can name the subquery in the query, and put it at the front of the SELECT statement.Author :: Old Wow's paw attilax ayron, email:[email protected]Reprin
Determine whether data exists
If exists (select * From hong_pageconfig where names = 'name') Begin print '1' endelse begin print '0' end
----------------- Determine whether the table name to be created existsIf exists (select * From DBO. sysobjects where id = object_id (n'[DBO]. [
Oracle database The process of creating temporary tables and the contrast with the different points of the SQL Server Temp table is the main content of this article, let's take a look at this part of the content, we hope to be able to help you.
1. Introduction
In addition to saving permanent tables, Oracle databases can also create temporary tables temporary ta
Usage:
You can use temporary tables to hold related records for complex queries, which can improve efficiency and readability of your programs, similar to those in cursors
My_cursor DECLARE my_cursor cursor scroll
For select field from tablename
Temporary tables are divided into: User temporary tables and system temporary tables.
The difference between a system temp table and a user temporary
table to resolve. A nested stored procedure can also create a temporary table with the same name as the temporary table created by the stored procedure that called it. All references to table names in a nested stored procedure are interpreted as tables created for the nested procedure, for example: CREATE PROCEDURETes
A temporary table is a table that is built into a temporary system folder and, if used properly, can be done in a variety of ways, like a normal table, and automatically released when VFP (Visual FoxPro, the latest Visual database management system platform introduced by Microsoft) exits.You can create local and global temporary tables. Local temporary tables are
Tags: des style blog http io ar color OS useOriginal: "T-SQL Series" Temp table, table variableTemp tableA temporary table is similar to a permanent table, except that it is created in tempdb and only disappears after the end of a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.