1 / 14

SQL Server “Denali” CTP3 Sequence

User Group Italiano SQL Server. Danilo Dominici. ddominici@sqlserverinfo.it. SQL Server “Denali” CTP3 Sequence. Speaker. +15 anni su SQL Server Consulente e docente Disegno, amministrazione, tuning di SQL Server dalla versione 6.5 MCSE, MCAD, MCDBA, MCITP, MCT

coyne
Download Presentation

SQL Server “Denali” CTP3 Sequence

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. User Group Italiano SQL Server Danilo Dominici ddominici@sqlserverinfo.it SQL Server “Denali” CTP3Sequence

  2. Speaker +15 anni su SQL Server • Consulente e docente • Disegno, amministrazione, tuning di SQL Server dalla versione 6.5 • MCSE, MCAD, MCDBA, MCITP, MCT • Microsoft Community Contributor Award 2011 Dal 2004 DBA in Regione Marche, VMWareadministrator Collaborazione attiva con UGISS • Speaker e autore Danilo Dominici UGISS - User Group Italiano SQL Server

  3. Agenda • L’oggetto SEQUENCE • Che cos’è • Come si usa • CACHE e prestazioni • Scenari d’uso UGISS - User Group Italiano SQL Server

  4. SEQUENCE E’ un generatoredinumeri (ANSI standard) Indipendente, legato ad uno schema, non ad altrioggetti del db Puòessereusato come la IDENTITY specificando NEXT VALUE FOR come valoredi default del campo Al contrariodellaproprietà IDENTITY però: • Puòessereutilizzatadirettamenteda T-SQL • E’ indipendentedallatabellache lo utilizza • Puòessereusatacontemporaneamentedapiùtabelle (o campi) del database Checos’è UGISS - User Group Italiano SQL Server

  5. SEQUENCE Con ilcomando CREATE SEQUENCE Ad esempio: CREATE SEQUENCE dbo.MySequence START WITH 1 INCREMENT BY 1; Possodefinire in chemodogenerare la sequenzadivalori: • All’internodi un range specificato (min e max) • Ascendente o discendente (incrementonegativo) • Valoreiniziale (puòesserediversodalvaloreminimo) • Ciclica Come sicrea UGISS - User Group Italiano SQL Server

  6. SEQUENCE Come si crea Da SSMS UGISS - User Group Italiano SQL Server

  7. SEQUENCE Richiedendo un valore singolo Attraverso la funzione NEXT VALUE FOR • Restituisce il prossimo valore numerico della sequenza • Può essere usata in stored procedure, trigger, default Maggiori info sul BOLhttp://msdn.microsoft.com/en-us/library/ff878370(v=sql.110).aspx Come siusa UGISS - User Group Italiano SQL Server

  8. SEQUENCE Richiedendo un “pool” di valori Attraverso la storedprocsp_sequence_get_range • Accetta come parametri il nome della sequenza ed il numero di valori da assegnare • Restituisce nei parametri di output (opzionali) il primo e l’ultimo valore, il numero di cicli già compiuti, i valori di incremento, minimo e massimo impostati per la sequenza • Da usare quando alla mia applicazione servono nvalori sequenziali tutti insieme Maggiori info sul BOLhttp://msdn.microsoft.com/en-us/library/ff878352v=sql.110).aspx Come siusa UGISS - User Group Italiano SQL Server

  9. SEQUENCE Tramitel’opzione CACHE possiamorichiederel’usodella cache e modificarnela dimensione Serve a migliorare le prestazioniminimizzandol’I/O su disco • Se non specificata, la dimensionedi default è di 50 valori(nella CTP3, potrebbecambiarenella RTM) • In realtà SQL Server mantiene due soli numeri: ilvalorecorrenteedilnumero di valoririmasti in cache E’ un estensionedi SQL Server allo standard ANSI E’ possibilespecificare NO CACHE, ma ognivoltachesirichiede un valore, SQL Server deveaggiornare le tabelle di sistema Caching e prestazioni UGISS - User Group Italiano SQL Server

  10. SEQUENCE Quandousare SEQUENCE ? • L’applicazionerichiede un numero prima di fare la INSERT • Piùtabelle (o colonne) devonocondividere la stessanumerazione • La numerazionedevericominciare al raggiungimento del limite • I valoridellasequenzadevonoesseregeneratiordinandolisulla base di un altro campo dellatabella • L’applicazionerichiede un range divaloripreassegnati • Occorremodificare a runtime le specifichedellasequenza (es. cambiarneilvalorediincremento) Scenaridiutilizzo UGISS - User Group Italiano SQL Server

  11. SEQUENCE Limitazioni • Nessunaprotezioneda UPDATE • Univocità non garantita by design • Nessuncontrollosull’utilizzodeivalorigenerati • Se creata con l’opzione CACHE, in casodi shutdown improvvisosipossonocrearebuchinellanumerazione Scenaridiutilizzo UGISS - User Group Italiano SQL Server

  12. SEQUENCE UGISS - User Group Italiano SQL Server

  13. SEQUENCE Presentazione e demo • http://www.ugiss.org Informazioni sul prodotto SQL Server • http://www.microsoft.com/italy/sql • http://www.microsoft.com/sql Supporto sviluppo ed professionisti IT • http://www.microsoft.com/technet/prodtechnol/sql • http://msdn.microsoft.com/sql Comunità SQL Server • http://www.ugiss.org Newsgroups pubblici via NTTP • microsoft.public.it.sql • microsoft.public.sqlserver.* Newsgroups pubblici via WEB • http://www.microsoft.com/italy/communities/newsgroups/default.mspx • http://www.microsoft.com/technet/community/newsgroups/server/sql.mspx Formazione • http://www.microsoft.com/italy/traincert Risorse Generiche UGISS - User Group Italiano SQL Server

  14. SEQUENCE SQL Server “Denali” Books On-Line • Sequence numbers • CREATE SEQUENCE • NEXT VALUE FOR • sp_sequence_get_range • sys.sequences Articoli magazines • SQL Server Magazine - Itzik Ben-Gan (parte 1) • SQL Server Magazine - Itzik Ben-Gan (parte 2) Blogs • Sergio Govoni (SQL Server MVP) • Aaron Bertrand (SQL Server MVP) • SSMA Team Blog - Converting Oracle Sequence using SSMA for Oracle v5.1 Risorse Specifiche UGISS - User Group Italiano SQL Server

More Related