Passa ai contenuti principali

Post

Visualizzazione dei post con l'etichetta MySQL

MariaDB CREATE TABLE mysql.index_stats

da  https://mariadb.com/kb/en/mariadb/mysqlindex_stats-table/ CREATE TABLE mysql.index_stats (    db_name VARCHAR(64) COMMENT 'Database the table is in.',    table_name VARCHAR(64) COMMENT 'Table name',    index_name VARCHAR(64) COMMENT 'Name of the index',    prefix_arity INT(11) UNSIGNED COMMENT 'Index prefix length. 1 for the first keypart, 2 for the first two, and so on. InnoDB\'s extended keys are supported.',    avg_frequency DECIMAL(12,4) DEFAULT NULL COMMENT 'Average number of records one will find for given values of (keypart1, keypart2, ..), provided the values will be found in the table.',   PRIMARY KEY (db_name, table_name, index_name, prefix_arity) ) ENGINE = InnoDB ROW_FORMAT = DEFAULT;

MariaDB CREATE TABLE mysql.column_stats

da https://mariadb.com/kb/en/mariadb/mysqlcolumn_stats-table/ CREATE TABLE mysql.column_stats (    db_name VARCHAR(64) NOT NULL COMMENT 'Database the table is in.',    table_name VARCHAR(64) NOT NULL COMMENT 'Table name.',    column_name VARCHAR(64) NOT NULL COMMENT 'Name of the column.',    min_value VARCHAR(64) DEFAULT NULL COMMENT 'Minimum value in the table (in text form).',    max_value VARCHAR(64) DEFAULT NULL COMMENT 'Maximum value in the table (in text form).',    nulls_ratio DECIMAL(12,4) DEFAULT NULL COMMENT 'Fraction of NULL values (0 - no NULLs, 0.5 - half values are NULLs, 1 - all values are NULLs).',    avg_length DECIMAL(12,4) DEFAULT NULL COMMENT 'Average length of column value, in bytes. Counted as if one ran SELECT AVG(LENGTH(col)). This doesn\'t count NULL bytes, assumes endspace removal for CHAR(n), etc.',    avg_frequency DECIMAL(12,4) DEFAULT NULL COMMENT 'Average number of re...

Script MySQL che ignorano constraint

Può essere comodo eseguire script MySQL di creazione/modifica/eliminazione di tabelle che non controllano eventuali foreign key. Ecco come: -- salvo le impostazioni attuali e disabilito il controllo SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; DROP TABLE ... CREATE TABLE ... ALTER TABLE ... -- rimetto le impostazioni di prima SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; enjoy /m

Resettare la password di MySQL su Windows, senza averla

Può succedere di perdere la password di MySQL su Windows :-0 Non è un problema, con questa procedura se ne può forzare un'altra. 1. Stoppare l'eventuale servizio di MySQL 2. Far partire MySQL senza grant tables Andare nella directory bin di MySQL e da DOS farlo partire in questo modo: mysqld --skip-grant-tables Questa finestra rimarrà aperta e come bloccata. 3. Entrare in MySQL mysql --user=root mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.0.45-community-nt MySQL Community Edition (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 4. Impostare la nuova password (nell'esempio: "mazzullami") mysql> update user set Password=PASSWORD(' mazzullami ') WHERE User='root'; Query OK, 2 rows affected (0.05 sec) Rows matched: 2 Changed: 2 Warnings: 0 5. Aggiornare le tabelle mysql> flush privileges; Query OK, 0 rows affected (0.02 sec) 6. Uscire ...

MySQL help

Ecco alcuni appunti sintetici per l'uso di MySQL da linea di comando. Connettersi mysql -h host -u user -p Caricare un file sql mysql -h localhost -u root -p DbName < textfile.sql Esportare un database (MySQLdump) mysqldump -h localhost -u root -p DbName > textfile.sql Opzioni utili possono essere: --single-transaction One single transaction -d|--no-data No row information. -l|--lock-tables Lock all tables for read. Permessi GRANT ALL PRIVILEGES ON *.* TO 'utente'@'localhost' IDENTIFIED BY 'pass' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO 'utente'@'%' IDENTIFIED BY 'pass' WITH GRANT OPTION; GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost'; GRANT USAGE ON *.* TO 'utente'@'localhost'; link utili: http://www.hmug.org/man/1/mysqldump.php http://dev.mysql.com

I tipi dati in MySQL

Due tabelline comode comode per numeri e stringhe. I numeri sono in formato americano. Numeri   Signed Unsigned   da a da a TINYINT[( M )] -128 127 0 255 SMALLINT[( M )] -32768 32767 0 65535 MEDIUMINT[( M )] -8388608 8388607 0 16777215 INT[( M )] INTEGER[( M )] -2147483648 2147483647 0 4294967295 BIGINT[( M )] -9,223E+18 9,223E+18 0 1,844E+19 SERIAL alias di BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE FLOAT[( M , D )] Valori da -3.402E+38 a -1.175E-38, 0, e 1.175E-38 a 3.402E+38 DOUBLE[( M , D )] Valori da -1.797E+308 a -2.225E-308, 0, e 2.225E-308 a 1.797E+308. DECIMAL[( M [, D ])] M è il numero di cifre (numero massimo : 65, default: 10 ) D sono i decimali (numero massimo: 30) Valori da MySQL 5.0.3 Stringhe tipo da a   CHAR[( M )] 0 255   VARCHAR( M ) 0 65,535 Da MySQL 5.0.3   0 255 Prima di MySQ...

Tipi di tabella in MySQL

[under construction] MyISAM is a disk based storage engine. Aiming for very low overhead, it does not support transactions. InnoDB is also disk based, but offers versioned, fully ACID transactional capabilities. InnoDB requires more disk space than MyISAM to store its data, and this increased overhead is compensated by more aggressive use of memory caching, in order to attain high speeds. Memory (formerly called "HEAP") is a storage engine that utilizes only RAM. Special algorithms are used that make optimal use of this environment. It is very fast. NDB , the MySQL Cluster Storage engine, connects to a cluster of nodes, offering high availability through redundancy, high performance through fragmentation (partitioning) of data across multiple node groups, and excellent scalability through the combination of these two. NDB uses main-memory only, with logging to disk. Vedi... http://dev.mysql.com/tech-resources/articles/storage-engine/part_1.html