My SQL Un Data Base Management System DBMS
My. SQL Un Data. Base Management System (DBMS) relazionale client/server. Michele Braidotti michele. braidotti@lncib. it
References ● ● ● http: //dev. mysql. com/doc/mysql/en/index. html Luke Welling, Laura Thomson: My. SQL Tutorial. My. SQL Press 2004. ISBN: 0 -672 -32584 -5. Paul Du. Bois: My. SQL, second edition. Sams 2003. ISBN: 0 -735 -71212 -3.
Caratteristiche My. SQL ● E' un Database Management System (DBMS). ● E' un DBMS Relazionale. ● Ha una struttura Client/Server. ● Ampiamente compatibile con lo standard SQL: – vedere 1. 8. 5 My. SQL Differences from Standard SQL.
Differenze con gli altri DBMS ● Microsoft Access, Filemaker: – ● Microsoft SQL Server, Postgresql, Informix, Sybase: – ● visuali, non client/server. simili a My. SQL. Oracle, SAP, DB 2: – completi, ma complessi.
Tipi di Tabelle (Storage Engines) I primi due tipi non supportano le chiavi esterne; il terzo tipo sì. ● ISAM. ● My. ISAM, HEAP (MEMORY), MERGE. ● Inno. DB, BDB.
L’uso di My. SQL (1) ● Esempi di utilizzo di My. SQL: – Connessione al Server. ● – Esecuzione di query. ● ● ● Gestione degli accessi. Inserimento, cancellazione, modifica. Selezione. Strumenti per l'amministrazione e lo sviluppo di basi di dati. – phpmyadmin.
L’uso di My. SQL (2) ● ● Si deve usare un programma detto My. SQL client. My. SQL deve sapere chi è l'utente: autenticazione. Vengono concessi i diritti che l'utente possiede. Deve essere consentito allo stesso utente o ad altri utenti di usare il Server.
L’uso di My. SQL (3) ● Come fa My. SQL a riconoscere gli utenti? ● La base di dati My. SQL. ● Le tabelle con i diritti. ● L'interprete dei comandi.
L’uso di My. SQL (4) Note all'uso dell'interprete dei comandi: ● E' case sensitive solo rispetto ai nomi degli attributi, tabelle in ambiente *nix. ● Ogni comando termina con “; ”. ● Prestare attenzione a ' “ ` – – ' e “ delimitano le stringe; ` delimitano i nomi degli attributi e delle tabelle. select `User` f. ROm `user` Where user LIKE 'm%' or user like "r%";
L’uso di My. SQL (5) Creazione: CREATE DATABASE [IF NOT EXISTS] db_name CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition, . . . )][table_options][select_statement] I nomi degli attributi e i loro tipi vengono specificati nella create_definition.
L’uso di My. SQL (6) L'inserimento dei dati: INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [(col_name, . . . )] VALUES ({expr | DEFAULT}, . . . ), (. . . ), . . . [ ON DUPLICATE KEY UPDATE col_name=expr, . . . ] INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name SET col_name={expr | DEFAULT}, . . . [ ON DUPLICATE KEY UPDATE col_name=expr, . . . ] INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name[(col_name, . . . )] SELECT. . .
L’uso di My. SQL (7) SELECT [STRAIGHT_JOIN][SQL_SMALL_RESULT][SQL_BIG_RESULT] [SQL_BUFFER_RESULT][SQL_CACHE | SQL_NO_CACHE][SQL_CALC_FOUND_ROWS][HIGH_PRIORITY][DI STINCT | DISTINCTROW | ALL] select_expression, . . . [FROM table_references] [WHERE where_definition] [GROUP BY {unsigned_integer | col_name | formula} [ASC | DESC], . . . ] [HAVING where_definition] [ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] , . . . ] [LIMIT [offset, ] rows | rows OFFSET offset]
L’uso di My. SQL (8) dove: ● select_expression. Indica le colonne che si vogliono restituire. ● table_references. Indica le tabelle dalle quali ricavare le colonne da restituire: – ● table_name [[AS] alias] where_definition. Specifica le condizioni cui devono soddisfare gli elementi delle tabelle specificate precedentemente.
- Slides: 13