This tutorial assumes you have created the test database. If you have not, see Lesson 1: Creating the test database.
You can copy and paste the SQL statements in this tutorial into Interactive SQL.
Start Sybase Central and connect to the test database app_profiling.db with the user ID DBA and the password sql.
If you are unfamiliar with starting Sybase Central and connecting to a database, see Connect to a local database.
In the left pane, click app_profiling - DBA, and then choose File » Open Interactive SQL.
Interactive SQL starts and connects to the app_profiling.db database.
In Interactive SQL, run the following SQL statements:
Create two tables
CREATE TABLE "DBA"."deadlock1" ( "id" UNSIGNED BIGINT NOT NULL DEFAULT AUTOINCREMENT, "val" CHAR(1) ); CREATE TABLE "DBA"."deadlock2" ( "id" UNSIGNED BIGINT NOT NULL DEFAULT AUTOINCREMENT, "val" CHAR(1) ); |
Insert values into each table
INSERT INTO "deadlock1"("val") VALUES('x'); INSERT INTO "deadlock2"("val") VALUES('x'); |
Create two procedures which you later use to cause the deadlock
CREATE PROCEDURE "DBA"."proc_deadlock1"( ) BEGIN LOCK TABLE "DBA"."deadlock1" IN EXCLUSIVE MODE; WAITFOR DELAY '00:00:20:000'; UPDATE deadlock2 SET val='y'; END; CREATE PROCEDURE "DBA"."proc_deadlock2"( ) BEGIN LOCK TABLE "DBA"."deadlock2" IN EXCLUSIVE MODE; WAITFOR DELAY '00:00:20:000'; UPDATE deadlock1 SET val='y'; END; |
Commit the changes you made to the database
COMMIT; |
Exit Interactive SQL.
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |