tutorial sqlcommand

Ejemplo 1

Crear una tabla

1.- Primero creamos una base de datos para empezar a trabajar, pulsamos "Archivo/Nueva Base de Datos" o Ctrl+N, llamamos a la base "ejemplo_1.mdb".

tutorial de sql con sqlcommand

2.- Una vez creada la base de datos ejemplo_1.mdb creamos la tabla alumnos, para lo cual introducimos en la ventana superior el siguiente comando sql y pulsamos ejecutar.

CREATE TABLE alumnos (	
			id LONG,
			nombre TEXT(30),
			apellidos TEXT(50),
			curso SHORT,
			fecha_nacimiento DATETIME);
tutorial de sql con sqlcommand

3.- Ya hemos creado la tabla alumnos y podemos introducir datos, para lo cual introcucimos las siguientes instrucciones y pulsamos ejecutar.


INSERT INTO alumnos VALUES(1,"JUAN",  "GARCIA PEREZ",     3,"01/01/1985");
INSERT INTO alumnos VALUES(2,"MARIA", "PEREZ GUTIERREZ",  3,"01/01/1985");
INSERT INTO alumnos VALUES(3,"JOSE",  "MARTINEZ CUESTA",  1,"01/01/1987");
INSERT INTO alumnos VALUES(4,"PILAR", "GARCIA ALVAREZ",   1,"01/01/1987");

INSERT INTO alumnos VALUES(5,"PALOMA","LOPEZ GARCIA",     3,"01/01/1985");
INSERT INTO alumnos VALUES(6,"PEDRO", "GONZALEZ GONZALEZ",1,"01/01/1987");

INSERT INTO alumnos VALUES(7,"PALOMA","MARTINEZ CUESTA",  2,"01/01/1986");
INSERT INTO alumnos VALUES(8,"RAUL",  "GARCIA SANCHEZ",   3,"01/01/1985");
tutorial de sql con sqlcommand

4.- Ya hemos creado nuestra primera tabla y hemos introducido datos en ella, para ver la tabla alumnos solo tenemos que pulsar en alumnos, veriamos lo siguiente:

tabla  alumnos

id

Long

4

nombre

Text

30

apellidos

Text

50

curso

Short

2

fecha_nacimiento

Date/Time

8

1JUANGARCIA PEREZ301/01/1985
2MARIAPEREZ GUTIERREZ301/01/1985
3JOSEMARTINEZ CUESTA101/01/1987
4PILARGARCIA ALVAREZ101/01/1987
5PALOMALOPEZ GARCIA301/01/1985
6PEDROGONZALEZ GONZALEZ101/01/1987
7PALOMAMARTINEZ CUESTA201/01/1986
8RAULGARCIA SANCHEZ301/01/1985