For the complete documentation index, see llms.txt. This page is also available as Markdown.

TYPE OF

Declare variables based on existing types. This feature allows defining variables or parameters that inherit the data type of a table column or another variable.

Overview

This is special declaration only available inside a stored procedure.

EXAMPLES

CREATE TABLE typeof_table(
  descr VARCHAR(20),
  val INT
);
INSERT INTO typeof_table VALUES ('Life', 42);
DELIMITER $$
CREATE PROCEDURE typeof_proc()
BEGIN
  DECLARE descr TYPE OF typeof_table.descr;
  DECLARE val TYPE OF typeof_table.val;
  SELECT * INTO descr, val FROM typeof_table;
  SELECT descr, val;
END;
$$
DELIMITER ;

This page is: Copyright © 2025 MariaDB. All rights reserved.

spinner

Last updated

Was this helpful?