Está en la página 1de 3

Instrucción Propósito Clausula Ejemplo de cada Clausula

. CREATE CREATE CREATE [OR REPLACE]


DATABASE DATABASE db1; {DATABASE | SCHEMA} [IF NOT
crea una base de Query OK, 1 row EXISTS] db_name
datos con el affected (0.18 sec) [create_specification] ...
nombre dado. Para
usar esta
Create declaración,
CREATE create_specification:
DATABASE db1; [DEFAULT] CHARACTER SET
Database necesita
el privilegio ERROR 1007 [=] charset_name
CREATE para la (HY000): Can't | [DEFAULT] COLLATE [=]
base de create database collation_name
datos. CREATE 'db1'; database
SCHEMA exists
es un sinónimo
de CREATE
DATABASE.
Esta declaración CREATE EVENT REATE [OR REPLACE]
Create crea y programa myevent [DEFINER = { user |
un ON SCHEDULE CURRENT_USER | role |
Event
nuevo evento . Re AT CURRENT_ROLE }]
quiere el CURRENT_TIMES EVENT
EVENT TAMP + [IF NOT EXISTS]
privilegio para el INTERVAL 1 event_name
esquema en el HOUR ON SCHEDULE schedule
que se creará el DO [ON COMPLETION [NOT]
evento. UPDATE PRESERVE]
myschema.mytabl [ENABLE | DISABLE | DISABLE
e SET mycol = ON SLAVE]
mycol + 1; [COMMENT 'comment']
DO sql_statement;

. Use la CREATE CREATE CREATE [OR REPLACE]


Create FUNCTION FUNCTION hello (s [DEFINER = {user |
Function declaración para CHAR(20)) CURRENT_USER | role |
crear una RETURNS CURRENT_ROLE }]
nueva función CHAR(50) [AGGREGATE] FUNCTION [IF
almacenada . De DETERMINISTIC NOT EXISTS] func_name
be tener RETURN ([func_parameter[,...]])
el CREATE CONCAT('Hello, RETURNS type
ROUTINE ',s,'!'); [characteristic ...]
privilegio RETURN func_body
de la base de
datos para func_parameter:
usar CREATE param_name type
FUNCTION.
Crea CREATE CREATE
Create un procedimiento PROCEDURE [OR REPLACE]
Procedure almacenado . Por simpleproc (OUT [DEFINER = { user |
defecto, una param1 INT) CURRENT_USER | role |
rutina está BEGIN CURRENT_ROLE }]
asociada a la SELECT PROCEDURE sp_name
base de datos COUNT(*) INTO ([proc_parameter[,...]])
predeterminada. param1 FROM t; [characteristic ...] routine_body
Para asociar la END;
rutina // proc_parameter:
explícitamente [ IN | OUT | INOUT ]
con una base de DELIMITER ; param_name type
datos dada,
especifique el CALL type:
nombre como simpleproc(@a); Any valid MariaDB data type
db_name.sp_na
me cuando lo
cree.
CREATE CREATE CREATE [OR REPLACE]
SEQUENCE SEQUENCE s [TEMPORARY] SEQUENCE [IF
creará una START WITH 100 NOT EXISTS] sequence_name
secuencia que INCREMENT BY [ INCREMENT [ BY | = ] increment
Create genera nuevos
10; ]
valores cuando se
SEQUENCE le llama NEXT
[ MINVALUE [=] minvalue | NO
VALUE FOR CREATE MINVALUE | NOMINVALUE ]
sequence_name. Es SEQUENCE s2 [ MAXVALUE [=] maxvalue | NO
una alternativa START WITH -100 MAXVALUE | NOMAXVALUE ]
al INCREMENTO INCREMENT BY - [ START [ WITH | = ] start ]
AUTOMÁTICO cua 10; [ CACHE [=] cache | NOCACHE ] [
ndo uno quiere CYCLE | NOCYCLE]
tener más control [table_options]
de cómo se
generan los
números.
Create Use la CREATE create table if not CREATE [OR REPLACE] [TEMPORARY]
Table TABLE exists test ( TABLE [IF NOT EXISTS] tbl_name
declaración para a bigint (create_definition,...) [table_options
crear una tabla auto_increment ]... [partition_options]
con el nombre de primary key, CREATE [OR REPLACE] [TEMPORARY]
pila. Debe tener name varchar(128) TABLE [IF NOT EXISTS] tbl_name
el CREATE charset utf8, [(create_definition,...)] [table_options
privilegio para la key name ]... [partition_options]
tabla o en la base (name(32)) select_statement
de datos para ) engine=InnoDB CREATE [OR REPLACE] [TEMPORARY]
crear una tabla. default charset TABLE [IF NOT EXISTS] tbl_name
latin1; { LIKE old_table_name | (LIKE
old_table_name) }
Create La CREATE CREATE [OR REPLACE] USER [IF
CREATE USER foo2@t
USER NOT EXISTS]
User est IDENTIFIED BY
user_specification
declaración crea 'password';
nuevas cuentas [,user_specification] ...
[REQUIRE {NONE | tls_option [[AND]
MariaDB. Para
tls options, tls_option] ...}]
usarlo, debe [WITH resource_option
tener el CREATE from MariaDB 10.2.0:
[resource_option] ...]
USER
privilegio global o CREATE USER 'foo4' user_specification:
el INSERT @'test'
username [authentication_option]
privilegio para la
base de datos REQUIRE ISSUER '
foo_issuer'
mysql.
SUBJECT 'foo_sub
ject'

CIPHER 'text'

Create CREATE
CREATE TABLE t (a
View INT, b INT) ENGINE [OR REPLACE]
= InnoDB; [ALGORITHM = {UNDEFINED | MERGE |
TEMPTABLE}]
[DEFINER = { user | CURRENT_USER |
role | CURRENT_ROLE }]
INSERT INTO t VALU [SQL SECURITY { DEFINER | INVOKER }]
ES (1,1), (2,2), ( VIEW [IF NOT EXISTS] view_name
3,3); [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK
OPTION]
CREATE VIEW v AS S
ELECT a, a*2 AS a2
FROM t;