Documentos de Académico
Documentos de Profesional
Documentos de Cultura
otras 2 tablas,
Hacemos clic en LA TABLA INSCRIPCION y en la barra inferior la opcin FOREGEIN KEYS
(click) y
Hacemos lo siguiente:
CLICK EN NEXT
MARCAR LA
PRIMERA OPCION Y CLICK EN NEXT
COMO PUEDE
VER AUTOMATICAMENTE SE HA GENERADO EL
SQL SCRIPT (O CODIGO) PARA GENERAR LA
BASE DE DATOS, LAS TRES TABLAS
Columnas numricas:
auto_increment --> para generar identificadores nicos o valores en serie.
unisgned --> rechazo de valores negativos
Cadena:
binary --> trata los valores como cadenas binarias (campos char y varchar)
Clusulas:
primary key --> columna indexada para bsqueda rpida. Clave principal, solo puede
haber una
unique --> crea un ndice con valores nicos
index, key --> son sinnimos y crean ndices que pueden contener valores repetidos.
CODIGO:
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,
ALLOW_INVALID_DATES';
Las restricciones UNIQUE y las restricciones CHECK son dos tipos de restricciones que se
pueden usar para exigir la integridad de los datos en las tablas de SQL Server. Se trata de
objetos de base de datos importantes.
Restricciones UNIQUE
Las restricciones son reglas que Motor de base de datos de SQL Server aplica de forma
automtica. Por ejemplo, puede usar restricciones UNIQUE para garantizar que no se escriben
valores duplicados en columnas especficas que no forman parte de una clave principal. Tanto
la restriccin UNIQUE como la restriccin PRIMARY KEY exigen la unicidad; sin embargo,
debe usar la restriccin UNIQUE y no PRIMARY KEY si desea exigir la unicidad de una
columna o una combinacin de columnas que no forman la clave principal.
Restricciones CHECK
Las restricciones CHECK exigen la integridad del dominio mediante la limitacin de los valores
que puede aceptar una o varias columnas. Puede crear una restriccin CHECK con cualquier
expresin lgica (booleana) que devuelva TRUE (verdadero) o FALSE (falso) basndose en
operadores lgicos. Por ejemplo, es posible limitar el intervalo de valores para una
columna salary creando una restriccin CHECK que solo permita datos entre 15 000 y 100 000
USD. Esto evita que los salarios caigan fuera del intervalo de salario normal. La expresin
lgica sera la siguiente: salary >= 15000 AND salary <= 100000.
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
FOREIGN_KEY_CHECKS=0;: Determines whether the server should check that a
referenced table exists when defining a foreign key. Due to potential circular references, this
check must be turned off for the duration of the import, to permit defining foreign keys. For
additional information, see foreign_key_checks.
FOREIGN_KEY_CHECKS option specifies whether or not to check foreign key constraints for InnoDB
tables.
Quick Example:
-- Specify to check foreign key constraints (this is the default)
SET FOREIGN_KEY_CHECKS = 1;
-- Do not check foreign key constraints
SET FOREIGN_KEY_CHECKS = 0;
Overview
MySQL FOREIGN_KEY_CHECKS option:
Syntax
SET FOREIGN_KEY_CHECKS = 0 | 1
Default
When Set to 1
SELECT @@FOREIGN_KEY_CHECKS
ALLOW_INVALID_DATES
Do not perform full checking of dates. Check only that the month is in the range from 1 to 12 and the
day is in the range from 1 to 31. This is very convenient for Web applications where you obtain year,
month, and day in three different fields and you want to store exactly what the user inserted (without
date validation). This mode applies to DATE and DATETIME columns. It does not
apply TIMESTAMP columns, which always require a valid date.
The server requires that month and day values be legal, and not merely in the range 1 to 12 and 1 to
31, respectively. With strict mode disabled, invalid dates such as '2004-04-31' are converted
to '0000-00-00' and a warning is generated. With strict mode enabled, invalid dates generate an
error. To permit such dates, enableALLOW_INVALID_DATES.
SQL bsico
Pregunta 1:
b) DROP TABLE
c) TRUNCATE TABLE
Pregunta 2:
En SQL, cul de estas sentencias aade una fila a una tabla en una
base de datos?
a) ADD
b) INSERT
c) UPDATE
d) INCLUDE
Pregunta 3:
b) LIKE "Juan*"
c) LIKE "Juan$"
d) LIKE "Juan&"
Pregunta 4:
a) DELETE
b) DROP
c) SELECT
d) UPDATE
Pregunta 5:
b) CHANGE TABLE
c) MODIFY TABLE
Pregunta 6:
a) LIKE "????"
b) LIKE "____"
c) LIKE "...."
Pregunta 7:
b) LIMIT()
c) MAX()
d) MIN()
Pregunta 8:
b) UNIQUE
c) DISTINCT
Pregunta 9:
En SQL, para ordenar los datos devueltos por una sentencia SELECT
se emplea la clusula
a) ORDER BY
b) ORDERED BY
c) SORT BY
d) SORTED BY
Pregunta 10:
b) FLOOR()
c) SUM()
Pregunta 11:
Pregunta 12:
b) DROP DATABASE
c) ERASE DATABASE