Está en la página 1de 5

INSTITUTO TECNOLÓGICO SUPERIOR CORDILLERA

T.S. DESARROLLO DE SOFTWARE

Segundo Nivel

Paralelo B - Jornada Matutina

Joaquín Cruz

Base de datos
Ejercicios de instrucciones de SQL SERVER

10 ejercicios con Insert

1. insert into dept(dept_no,dnombre,loc)

values(60,'informatica','madrid')

2. insert into emp (emp_no,apellido,oficio,fecha_alt,salario,comision,dept_no)

values(8596,'escriche','programador','07/02/02',70000,0,60)

3. insert into nombtabla

values (valor1, valor2, ...)

4. insert into alumnos (id_alumno , nombre , apellidos , f_nacimiento)


values (1 , 'pablo' , 'hernandaz mata' , '1995-03-14')

5. insert into "nombre_tabla" ("columna1", "columna2", ...)


values ("valor1", "valor2", ...);

6. insert into store_information (store_name, sales, txn_date)


values ('los angeles', 900, '10-jan-1999');

7. insert into "tabla1" ("columna1", "columna2", ...)


select "columna3", "columna4", ...
from "tabla2";
8. insert into store_information (store_name, sales, txn_date)
select store_name, sales, txn_date
from sales_information
where year (txn_date) = 1998;

9. insert into personas


values ('pedro', 'ruiz', 'gonzalez')
insert into personas (nombre, apellido1, apellido2)
values ('pedro', 'ruiz', 'gonzalez')

10. insert into personas


values (400, 'gonzalez', 20, 'venta', null, 18000,66, 0)

10 ejercicios con select

1. select * from clientes

2. select clientes.idcliente, clientes.nombre, clientes.descripcion from clientes

3. select numero, calle from direccion where ciudad = ‘quito’

4. select calle, ciudad from direccion where numero = 12

5. select nombre from clientes where edad <= 32

6. select nombre from clientes where edad between 20 and 35

7. select num, calle, cp from direccion where ciudad like ‘val%’

8. select num, calle, direccion


from direccion
where ciudad in (‘sevilla’, ’córdoba’, ‘huelva’, ‘cádiz’)

9. select * from ciudad order by provincia asc, numhabitantes desc

10. select day(fechalinea) as dia, floor(preciolinea * 0.85)


as preciodtoredondeado
from lineapedido
10 ejercicios con update

1. update mi_tabla set ciudad = 'quito' where nombre = 'joaquin';

2. update mi_tabla set ciudad = 'valencia'


where nombre = 'pepito' and ciudad = 'sevilla';

3. update customers
set contactname='juan'
where country='mexico';

4. update usuarios set clave='tribus234'


where nombre='federicolopez';

5. update customers
set contactname = 'alfred schmidt', city= 'frankfurt'
where customerid = 1;

6. update nombre_tabla set columna1 = 'nuevo_valor'


where columna1 = 'valor1';

7. update cursos set id_profe = 2


where id_curso = 5

8. update nombre_tabla
set columna1 = valor1, columna2 = valor2
where columna3 = valor3

9. update empleados set salario = salario * 1.02


precio_hora = precio_hora * 1.01
where salario < 3000

10. update personas set apellido2 = 'rodriguez'


where nombre = 'antonio' and apellido1 = 'garcia'
and apellido2 = 'benito'
10 ejercicios de delete

1. delete * from nombre_tabla;

2. delete from empleados


where estado = 'b'

3. delete * from pedidos where clie in

(select numclie from clientes

where nombre = 'julian lópez');

4. delete from personas where nombre = 'luis'


and apellido1 = 'lopez'
and apellido2 = 'perez'

5. delete from store_information


where store_name = 'quito';

6. delete from usuarios


where nombre='marcelo';

7. delete top 10 from nombre_tabla_empleado;

8. delete from nombre_tabla


where condiniones

9. delete from nombre_de_tabla where id < 100

10. delete from nombre_de_tabla where id < 100 and nombre <> 'administrador '

También podría gustarte