{"id":15249,"date":"2025-09-22T22:54:42","date_gmt":"2025-09-22T20:54:42","guid":{"rendered":"https:\/\/www.palentino.es\/blog\/?p=15249"},"modified":"2025-09-22T22:54:42","modified_gmt":"2025-09-22T20:54:42","slug":"%f0%9f%93%8c-chuleta-sql-objetos-programables","status":"publish","type":"post","link":"https:\/\/www.palentino.es\/blog\/%f0%9f%93%8c-chuleta-sql-objetos-programables\/","title":{"rendered":"&#x1f4cc; Chuleta SQL \u2013 Objetos programables"},"content":{"rendered":"<p>&#x1f4cc; Chuleta SQL \u2013 Objetos programables<br \/>\nEn SQL no todo son consultas. Puedes crear objetos programables que te ayudan a automatizar, organizar y optimizar tu base de datos.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.palentino.es\/blog\/wp-content\/uploads\/2025\/09\/objetos-programables-sql.jpg\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15250 size-full\" src=\"https:\/\/www.palentino.es\/blog\/wp-content\/uploads\/2025\/09\/objetos-programables-sql.jpg\" alt=\"\" width=\"517\" height=\"740\" srcset=\"https:\/\/www.palentino.es\/blog\/wp-content\/uploads\/2025\/09\/objetos-programables-sql.jpg 517w, https:\/\/www.palentino.es\/blog\/wp-content\/uploads\/2025\/09\/objetos-programables-sql-210x300.jpg 210w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/a><!--more--><\/p>\n<p>&#x1f539; Procedimiento almacenado (PROC)<br \/>\nBloque de c\u00f3digo reutilizable.<br \/>\nLo ejecutas con EXEC.<br \/>\nEjemplo: EXEC MiProc 10;<\/p>\n<p>&#x1f539; Trigger<br \/>\nC\u00f3digo que se dispara solo ante INSERT, UPDATE, DELETE.<br \/>\nIdeal para auditor\u00eda y validaciones.<br \/>\nUsa tablas internas: inserted, deleted.<\/p>\n<p>&#x1f539; Funci\u00f3n (UDF)<br \/>\nDevuelve un valor o tabla.<br \/>\nSe usa en SELECT, WHERE, etc.<br \/>\nEjemplo: SELECT dbo.Suma(2,3);<\/p>\n<p>&#x1f539; Vista (VIEW)<br \/>\nConsulta guardada como tabla virtual.<br \/>\nFacilita seguridad y reutilizaci\u00f3n.<br \/>\nEjemplo: SELECT * FROM VistaClientes;<\/p>\n<p>&#x1f539; Evento \/ Job<br \/>\nEjecuta tareas en horarios definidos (ej: backup).<br \/>\nAutom\u00e1tico, no manual.<\/p>\n<p>&#x1f539; Secuencia<br \/>\nGenerador de n\u00fameros consecutivos.<br \/>\nM\u00e1s flexible que IDENTITY.<br \/>\nEjemplo: NEXT VALUE FOR MiSeq<\/p>\n<p>&#x1f539; Paquete (Oracle)<br \/>\nAgrupa varios procedimientos y funciones.<\/p>\n<p>&#x1f449; Regla r\u00e1pida:<br \/>\nPROC = lo llamas t\u00fa<br \/>\nTRIGGER = salta solo<br \/>\nFUNCION = devuelve valor<br \/>\nVISTA = consulta guardada<br \/>\nJOB = programado<br \/>\nSECUENCIA = contador<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x1f4cc; Chuleta SQL \u2013 Objetos programables En SQL no todo son consultas. Puedes crear objetos programables que te ayudan a automatizar, organizar y optimizar tu base de datos. &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1415],"tags":[],"class_list":["post-15249","post","type-post","status-publish","format-standard","hentry","category-sin-categoria-es"],"_links":{"self":[{"href":"https:\/\/www.palentino.es\/blog\/wp-json\/wp\/v2\/posts\/15249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.palentino.es\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.palentino.es\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.palentino.es\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.palentino.es\/blog\/wp-json\/wp\/v2\/comments?post=15249"}],"version-history":[{"count":1,"href":"https:\/\/www.palentino.es\/blog\/wp-json\/wp\/v2\/posts\/15249\/revisions"}],"predecessor-version":[{"id":15251,"href":"https:\/\/www.palentino.es\/blog\/wp-json\/wp\/v2\/posts\/15249\/revisions\/15251"}],"wp:attachment":[{"href":"https:\/\/www.palentino.es\/blog\/wp-json\/wp\/v2\/media?parent=15249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.palentino.es\/blog\/wp-json\/wp\/v2\/categories?post=15249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.palentino.es\/blog\/wp-json\/wp\/v2\/tags?post=15249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}