Diccionario MySQL
palabras repetidas
from=que tabla esta utilizando
where=condición
length=contar numero de caracteres en una palabra
CREAR TABLA
create table cargo
(
codigo_del_cargo int primary key,
nombre_del_cargo varchar(50),
estado varchar(30)
);
ATUALIZAR DATOS:
update cargo set nombre_cargo='ADMINISTRADOR GENERAL'
where codigo_CARGO='1526';
IMPORTAR ARCHIVO .csv
load data infile 'cargo.csv' into table cargo fields terminated by ';'
lines terminated by '\n';
MOSTRAR DEATOS DEL UNA TABLA
select * from cargo;
VER LOS TIPOS DE DATOS EN TABLA
describe cargo;
LLAVE FORANEA
alter table tabla_llave_foranea add constraint nombre_del_campo foreign key (nombre_del_campo) tabla_llave_principal (campo_llave_principal);
LLAVE FORANEA MULTIPLE
ALTER TABLE EMPLEADO ADD FOREIGN KEY (CARGO) REFERENCES CARGO
(ID_CARGO);
CAMBIAR TIPO DE DATO A UN CAMPO ALTER TABLE CARGO MODIFY nombre_cargo varchar (50);
CAMBIAR NOMBRE DE UN CAMPO
ALTER TABLE CARGO CHANGE CARGO ID_CARGO INT;
RELACIONES FORANEAS: ALTER TABLE detalle_venta ADD CONSTRAINT
cod_producto FOREIGN KEY (cod_producto) REFERENCES producto
(codigo_producto);
CAMBIAR A ENTERO: ALTER TABLE cliente MODIFY ciudad_residencia int;
Eliminar clave primaria: alter table nombre tabla drop primary key;
Agregar nueva clave primaria:alter table nombre tabla add primary key (nombre tabla);
ELIMINAR REGISTRO: DELETE Tabla.* FROM Tabla WHERE criterio
ESPACIO AL CONCATENAR:
mysql> select
concat_ws (' ', nombre_1,nombre_2,apellido_1,apellido_2) from cliente;
AGREGAR UN CAMPO:
ALTER TABLE personal ADD salario varchar(30) AFTER fecha_nacimiento;
...
Regístrate para leer el documento completo.