Search
 
SCRIPT & CODE EXAMPLE
 

SQL

what is delimiter in mysql

/*

Delimiters other than the default ; are typically used when defining functions, stored procedures, and triggers wherein you must define multiple statements. You define a different delimiter like $$ which is used to define the end of the entire procedure, but inside it, individual statements are each terminated by ;. That way, when the code is run in the mysql client, the client can tell where the entire procedure ends and execute it as a unit rather than executing the individual statements inside.

Note that the DELIMITER keyword is a function of the command line mysql client (and some other clients) only and not a regular MySQL language feature. It won't work if you tried to pass it through a programming language API to MySQL. Some other clients like PHPMyAdmin have other methods to specify a non-default delimiter.

*/

/* Example:*/

DELIMITER $$
/* This is a complete statement, not part of the procedure, so use the custom delimiter $$ */
DROP PROCEDURE my_procedure$$

/* Now start the procedure code */
CREATE PROCEDURE my_procedure ()
BEGIN    
  /* Inside the procedure, individual statements terminate with ; */
  CREATE TABLE tablea (
     col1 INT,
     col2 INT
  );

  INSERT INTO tablea
    SELECT * FROM table1;

  CREATE TABLE tableb (
     col1 INT,
     col2 INT
  );
  INSERT INTO tableb
    SELECT * FROM table2;
  
/* whole procedure ends with the custom delimiter */
END$$

/* Finally, reset the delimiter to the default ; */
DELIMITER ;
Comment

PREVIOUS NEXT
Code Example
Sql :: oracle leftmost characters 
Sql :: check if has alpha characters sql 
Sql :: check if value is equal to something sql 
Sql :: codigo crear tablas sql server 
Sql :: oracle apex view logs 
Sql :: linq join 
Sql :: sp in sql server 
Sql :: DATEDIFF minute postgres 
Sql :: how to select distinct in mysql 
Sql :: sql count null as 0 
Sql :: mysql check date range 
Sql :: mysql update column to be nullable 
Sql :: mysql version 
Sql :: how to lock table in mysql 
Sql :: snowflake drop column 
Sql :: how to access to mysql without root 
Sql :: alter column set not null to null postgres 
Sql :: postgresql get date from datetime 
Sql :: create table in sql server 
Sql :: partition by sql server 
Sql :: convert polygon to text in mysql 
Sql :: execute sp in sql server 
Sql :: T-SQL - Delete Column 
Sql :: mysql create procedure phpmyadmin 
Sql :: insert into values select 
Sql :: sample clause in sql 
Sql :: install latest mysql 8 linux server 
Sql :: sql server convert to guid 
Sql :: oracle concat datetime 
Sql :: sort order on two columns sql 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =