Apache Derby - Sintaxis

Este capítulo le brinda la sintaxis de todas las declaraciones SQL de Apache Derby.

Todas las declaraciones comienzan con cualquiera de las palabras clave como SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW y todas las declaraciones terminan con un punto y coma (;).

Las declaraciones SQL de Apache Derby son sensibles a mayúsculas y minúsculas, incluidos los nombres de las tablas.

Declaración CREATE

CREATE TABLE table_name (
   column_name1 column_data_type1 constraint (optional),
   column_name2 column_data_type2 constraint (optional),
   column_name3 column_data_type3 constraint (optional)
);

MESA PLEGABLE

DROP TABLE table_name;

INSERTAR declaración

INSERT INTO table_name VALUES (column_name1, column_name2, ...);

Sentencia SELECT

SELECT column_name, column_name, ... FROM table_name;

Declaración UPDATE

UPDATE table_name
   SET column_name = value, column_name = value, ...
   WHERE conditions;

Declaración DELETE

DELETE FROM table_name WHERE condition;

Declaración DESCRIBE

Describe table_name

Sentencia SQL TRUNCATE TABLE

TRUNCATE TABLE table_name;

Sentencia ALTER - Añadiendo columna

ALTER TABLE table_name ADD COLUMN column_name column_type;

Sentencia ALTER - Agregar restricción

ALTER TABLE table_name ADD CONSTRAINT constraint_name constraint (column_name);

Sentencia ALTER - Columna de descarte

ALTER TABLE table_name DROP COLUMN column_name;

Sentencia ALTER: restricción de eliminación

ALTER TABLE table_name DROP CONSTRAINT constraint_name;

Dónde cláusula

SELECT * from table_name WHERE condition;
or,
DELETE from table_name WHERE condition;
or,
UPDATE table_name SET column_name = value WHERE condition;

Cláusula GROUP BY

SELECT column1, column2, . . . table_name GROUP BY column1, column2, . . .;

Cláusula ORDER BY

SELECT * FROM table_name ORDER BY column_name ASC|DESC.

Tener cláusula

SELECT column1, column2 . . . from table_name GROUP BY column having
condition;

Creando índice

CTREATE INDEX index_name on table_name (column_name);

Creando un índice ÚNICO

CREATE UNIQUE INDEX index_name on table_name (column_name);

Crear un índice COMPUESTO

CREATE INDEX index_name on table_name (column_name1, column_name2);

Visualización de índices

SHOW INDEXES FROM table_name;

Eliminando índices

DROP INDEX index_name;