the GUID is automatically generated, that is, the table cannot be duplicated in the column, then the ID column cannot be passed into the @columns, such as: @columns = ' Stuname,stuage,stusex ',If you want to satisfy all the columns in the table that require no repetition: @columns = ' stuid,stuname,stuage,stusex ' in this form.2. Some classmates or colleagues want to ask why all the statements are stitched
General traffic is larger than the Web site, and the request log table is created independently of one table per day. The business needs to add a new column for each table, and for half a day, write a stored procedure like this:Log table
;end;//delimiter;call unionsp (' 20140730 ', ' 20140930 ', ' biz_date ')Union: The union means to merge two or more query results together.Requirements: Two queries must have the same number of columnsRecommendation: The type of column can be different, but the recommended query for each column, want the corresponding type to be the sameData that can come from multiple tables: The column names taken out by multiple SQL statements can be inconsistent, with the column name of the first SQL stateme
I. Dynamic execution of SQLPREPARE from ' Delete from Test ' ; EXECUTE S1;Second, using cursorsDECLARE CURSOR for SELECT from FJDC. V_i_dg_dm_zy_wl_zbhz_attr T; OPEN V_cursor; FETCH into V_deletesql,v_insertsql; CLOSE V_cursor;Third, while loop while true -do expression ENDwhile;Iv. DB2 query table data, generate dynamic SQL, and execute1 CREATE PROCEDURE" TEST". " TEST "()2 BEGIN3
SqlPager Stored Procedures
Copy Code code as follows:
ALTER proc [dbo]. [SqlPager]
(
@tblName varchar (255),--Table name (Note: You can link multiple tables)
@strGetFields varchar (1000) = ' * ',--columns to be returned
@OrderfldName varchar (255) = ',--sorted field name
@PageSize int = 10,--page size
@PageIndex int = 1,--page number
@doCount int = 1 output,--number of records queried
@
SQL Statement implementation:SELECT COUNT (*) from INFORMATION_SCHEMA. ' TABLES ' WHERE table_name= ' youtablename ';In the WHERE clause, the table name is a string type, and the single quotation mark is added.In the MySQL stored procedureFunction implementation:CREATE definer = ' root ' @ ' localhost ' FUNCTION ' tableexists ' (' tname ' varchar ()) RETURNS tinyint (4) Begindeclare Tableexists TINYINT DEFA
' asmessage -
$
the
the --Cycle Start
the
the while @intCounter @intCountProperties
-
in begin
the
the --take the first record
About
the Select @spid =spid@bl =BL the
the from#tmp_lock_whowhereId= @intCounter
+
- begin
the
Bayi if @spid =0
the
the Select 'causing the database deadlock is:'+ CAST(@bl as VARCHAR(Ten))+ 'process number, which executes the following SQL syntax'
-
- Else
the
the Select 'process number spid:'+ CAST(@spid
Tags: add case from ALTER TABLE name use ORA function name kill1. If the function is locked, then there must be a process using the functionSelect b.sid,b.serial# from Dba_ddl_locks A, v$session b Where a.session_id = b.sid and A.name = ' function name or table name ';2. Kill processes using commands in OracleAlter system kill session ' sid,serial# ';3. If you encounter a situation that cannot be killed in
MySQL Stored Procedure programming is a complex topic. In this chapter, we will provide you with the content to complete basic tasks, including:
1. How to Create a stored procedure
2. How to input and output stored procedures
3. How to interact with the database
4. How to Us
SQL database Stored Procedure example parsing and SQL stored procedure example
What is a stored procedure:Stored procedures can be said to be a record set, it is a code block composed of some T-SQL statements, these T-SQL statement code implements some functionality like a m
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 tables. These temporary tables are used to hold
temp table will be truncated
4 when to use temporary tables
1, when the table associated with a SQL statement is 2 and above, and is associated with some small tables. A large table can be split and a smaller set of results is stored in a temporary
Background
In the process of writing SQL Server stored procedures, there are often complex business logic, it is common practice to split a large stored procedure into several small stored procedures.
Problem
You need to call stored p
. 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
in the Stored Procedure
drop procedure if exists p_loop;delimiter;;create procedure p_loop(in parameter int)BEGIN declare var int; set var = parameter; LOOP_LABLE:loop set var = var - 1; set parameter = parameter -2; if var
Using LOOP to write the same LOOP control statement is more c
using flow control statements. With great flexibility, they can complete complicated judgment and computation.
(2) stored procedures allow standard components to be programmed. After a stored procedure is created, it can be called multiple times in the program without having to rewrite the SQL statement of the stored
View mysql stored procedure details and view mysql Stored Procedure
Stored ProcedureIn this way, we can encapsulate SQL statements that require special processing into functions. When necessary, we only need to call this function to implement the operations we want, this pro
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.