CREATE SYNONYM Statement - Oracle to MariaDB Migration

In Oracle, the CREATE SYNONYM statement defines an alternative name for a table, view, stored procedure, user-defined function, or other database object.

MariaDB currently does not support synonyms (see MDEV-16482), but you can use a view when you need an alternative name for a table or another view.

Oracle:

  -- You can create a synonym for an object that does not yet exist
  CREATE OR REPLACE SYNONYM s1 FOR t1;
  /* Synonym created. */
 
  CREATE TABLE t1 (c1 CHAR);
  /* Table created. */
 
  SELECT * FROM s1;
  /* no rows selected */

MariaDB:

  CREATE TABLE t1 (c1 CHAR);
  /* Query OK, 0 rows affected */
 
  -- You can create a view as an alternative name for a table
  CREATE OR REPLACE VIEW s1 AS SELECT * FROM t1;
  /* Query OK, 0 rows affected */
 
  SELECT * FROM s1;
  /* Empty set */

Note that Oracle allows creating a synonym even if the referenced object does not exist, whereas MariaDB only permits creating views for existing objects.

For more information, see Oracle to MariaDB Migration.