0% found this document useful (0 votes)
15 views1 page

SQL Comands

This document provides SQL commands for accessing and managing databases and tables in MySQL including creating databases and tables, inserting values, adding and dropping foreign keys, and updating values.

Uploaded by

Leonel Gunn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

SQL Comands

This document provides SQL commands for accessing and managing databases and tables in MySQL including creating databases and tables, inserting values, adding and dropping foreign keys, and updating values.

Uploaded by

Leonel Gunn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

acceso

mysql -u root -p

crear bd
CREATE DATABASE dbname;

entrar bd
USE dbname;

crear tabla e insertar valores


CREATE TABLE example ( id smallint unsigned not null auto_increment, name
varchar(20) not null, constraint pk_example primary key (id) );
INSERT INTO example ( id, name ) VALUES ( null, 'Sample data' );

borrar tabla
DROP TABLE tablename;

borrar bd
DROP DATABASE dbname;

llave foranea
ALTER TABLE Orders
ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);

ALTER TABLE Orders


ADD CONSTRAINT FK_PersonOrder
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);

borrar llave foranea


ALTER TABLE Orders
DROP FOREIGN KEY FK_PersonOrder;

ALTER TABLE Orders


DROP CONSTRAINT FK_PersonOrder;

ingresar valores
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

INSERT INTO table_name


VALUES (value1, value2, value3, ...);

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

You might also like