You are on page 1of 12

MariaDB [(none)]> help

General information about MariaDB can be found at


http://mariadb.org

List of all MySQL commands:


Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
notee (\t) Don't write into outfile.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog
with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.

For server side help, type 'help contents'

MariaDB [(none)]> /**


/*> questo � il mio commento multilinea
/*> sasasa
/*> */
MariaDB [(none)]> -- visualizzazione dei DB presenti
MariaDB [(none)]> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| form |
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
+--------------------+
6 rows in set (0.10 sec)

MariaDB [(none)]> select 11-8;


+------+
| 11-8 |
+------+
| 3 |
+------+
1 row in set (0.02 sec)

MariaDB [(none)]> select 11/8


-> ;
+--------+
| 11/8 |
+--------+
| 1.3750 |
+--------+
1 row in set (0.02 sec)

MariaDB [(none)]> select 11*8;


+------+
| 11*8 |
+------+
| 88 |
+------+
1 row in set (0.00 sec)

MariaDB [(none)]> select 11-8;


+------+
| 11-8 |
+------+
| 3 |
+------+
1 row in set (0.00 sec)

MariaDB [(none)]> select pow(36,2);


+-----------+
| pow(36,2) |
+-----------+
| 1296 |
+-----------+
1 row in set (0.02 sec)

MariaDB [(none)]> select sqrt(36);


+----------+
| sqrt(36) |
+----------+
| 6 |
+----------+
1 row in set (0.00 sec)

MariaDB [(none)]> select pow(3, 22) as "mio calcolo";


+-------------+
| mio calcolo |
+-------------+
| 31381059609 |
+-------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select PI();


+----------+
| PI() |
+----------+
| 3.141593 |
+----------+
1 row in set (0.00 sec)

MariaDB [(none)]> select PI() as PIGRECO;


+----------+
| PIGRECO |
+----------+
| 3.141593 |
+----------+
1 row in set (0.00 sec)

MariaDB [(none)]> use information_schema;


Database changed
MariaDB [information_schema]> show tables;
+---------------------------------------+
| Tables_in_information_schema |
+---------------------------------------+
| ALL_PLUGINS |
| APPLICABLE_ROLES |
| CHARACTER_SETS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS |
| COLUMN_PRIVILEGES |
| ENABLED_ROLES |
| ENGINES |
| EVENTS |
| FILES |
| GLOBAL_STATUS |
| GLOBAL_VARIABLES |
| KEY_CACHES |
| KEY_COLUMN_USAGE |
| PARAMETERS |
| PARTITIONS |
| PLUGINS |
| PROCESSLIST |
| PROFILING |
| REFERENTIAL_CONSTRAINTS |
| ROUTINES |
| SCHEMATA |
| SCHEMA_PRIVILEGES |
| SESSION_STATUS |
| SESSION_VARIABLES |
| STATISTICS |
| SYSTEM_VARIABLES |
| TABLES |
| TABLESPACES |
| TABLE_CONSTRAINTS |
| TABLE_PRIVILEGES |
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
| GEOMETRY_COLUMNS |
| SPATIAL_REF_SYS |
| CLIENT_STATISTICS |
| INDEX_STATISTICS |
| INNODB_SYS_DATAFILES |
| TABLE_STATISTICS |
| INNODB_SYS_TABLESTATS |
| USER_STATISTICS |
| INNODB_SYS_INDEXES |
| XTRADB_RSEG |
| INNODB_CMP_PER_INDEX |
| INNODB_TRX |
| CHANGED_PAGE_BITMAPS |
| INNODB_FT_BEING_DELETED |
| INNODB_LOCK_WAITS |
| INNODB_LOCKS |
| INNODB_TABLESPACES_ENCRYPTION |
| XTRADB_INTERNAL_HASH_TABLES |
| INNODB_SYS_FIELDS |
| INNODB_CMPMEM_RESET |
| INNODB_CMP |
| INNODB_FT_INDEX_TABLE |
| INNODB_SYS_TABLESPACES |
| INNODB_MUTEXES |
| INNODB_BUFFER_PAGE_LRU |
| INNODB_SYS_FOREIGN_COLS |
| INNODB_CMP_RESET |
| INNODB_BUFFER_POOL_STATS |
| INNODB_FT_INDEX_CACHE |
| INNODB_SYS_FOREIGN |
| INNODB_METRICS |
| INNODB_FT_DEFAULT_STOPWORD |
| INNODB_CMPMEM |
| INNODB_SYS_TABLES |
| INNODB_SYS_COLUMNS |
| INNODB_FT_CONFIG |
| INNODB_BUFFER_PAGE |
| INNODB_CMP_PER_INDEX_RESET |
| XTRADB_READ_VIEW |
| INNODB_SYS_SEMAPHORE_WAITS |
| INNODB_CHANGED_PAGES |
| INNODB_FT_DELETED |
| INNODB_TABLESPACES_SCRUBBING |
+---------------------------------------+
78 rows in set (0.02 sec)

MariaDB [information_schema]> select * from USER_PRIVILEGES


-> ;
+--------------------+---------------+-------------------------+--------------+
| GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
+--------------------+---------------+-------------------------+--------------+
| 'root'@'localhost' | def | SELECT | YES |
| 'root'@'localhost' | def | INSERT | YES |
| 'root'@'localhost' | def | UPDATE | YES |
| 'root'@'localhost' | def | DELETE | YES |
| 'root'@'localhost' | def | CREATE | YES |
| 'root'@'localhost' | def | DROP | YES |
| 'root'@'localhost' | def | RELOAD | YES |
| 'root'@'localhost' | def | SHUTDOWN | YES |
| 'root'@'localhost' | def | PROCESS | YES |
| 'root'@'localhost' | def | FILE | YES |
| 'root'@'localhost' | def | REFERENCES | YES |
| 'root'@'localhost' | def | INDEX | YES |
| 'root'@'localhost' | def | ALTER | YES |
| 'root'@'localhost' | def | SHOW DATABASES | YES |
| 'root'@'localhost' | def | SUPER | YES |
| 'root'@'localhost' | def | CREATE TEMPORARY TABLES | YES |
| 'root'@'localhost' | def | LOCK TABLES | YES |
| 'root'@'localhost' | def | EXECUTE | YES |
| 'root'@'localhost' | def | REPLICATION SLAVE | YES |
| 'root'@'localhost' | def | REPLICATION CLIENT | YES |
| 'root'@'localhost' | def | CREATE VIEW | YES |
| 'root'@'localhost' | def | SHOW VIEW | YES |
| 'root'@'localhost' | def | CREATE ROUTINE | YES |
| 'root'@'localhost' | def | ALTER ROUTINE | YES |
| 'root'@'localhost' | def | CREATE USER | YES |
| 'root'@'localhost' | def | EVENT | YES |
| 'root'@'localhost' | def | TRIGGER | YES |
| 'root'@'localhost' | def | CREATE TABLESPACE | YES |
| 'root'@'127.0.0.1' | def | SELECT | YES |
| 'root'@'127.0.0.1' | def | INSERT | YES |
| 'root'@'127.0.0.1' | def | UPDATE | YES |
| 'root'@'127.0.0.1' | def | DELETE | YES |
| 'root'@'127.0.0.1' | def | CREATE | YES |
| 'root'@'127.0.0.1' | def | DROP | YES |
| 'root'@'127.0.0.1' | def | RELOAD | YES |
| 'root'@'127.0.0.1' | def | SHUTDOWN | YES |
| 'root'@'127.0.0.1' | def | PROCESS | YES |
| 'root'@'127.0.0.1' | def | FILE | YES |
| 'root'@'127.0.0.1' | def | REFERENCES | YES |
| 'root'@'127.0.0.1' | def | INDEX | YES |
| 'root'@'127.0.0.1' | def | ALTER | YES |
| 'root'@'127.0.0.1' | def | SHOW DATABASES | YES |
| 'root'@'127.0.0.1' | def | SUPER | YES |
| 'root'@'127.0.0.1' | def | CREATE TEMPORARY TABLES | YES |
| 'root'@'127.0.0.1' | def | LOCK TABLES | YES |
| 'root'@'127.0.0.1' | def | EXECUTE | YES |
| 'root'@'127.0.0.1' | def | REPLICATION SLAVE | YES |
| 'root'@'127.0.0.1' | def | REPLICATION CLIENT | YES |
| 'root'@'127.0.0.1' | def | CREATE VIEW | YES |
| 'root'@'127.0.0.1' | def | SHOW VIEW | YES |
| 'root'@'127.0.0.1' | def | CREATE ROUTINE | YES |
| 'root'@'127.0.0.1' | def | ALTER ROUTINE | YES |
| 'root'@'127.0.0.1' | def | CREATE USER | YES |
| 'root'@'127.0.0.1' | def | EVENT | YES |
| 'root'@'127.0.0.1' | def | TRIGGER | YES |
| 'root'@'127.0.0.1' | def | CREATE TABLESPACE | YES |
| 'root'@'::1' | def | SELECT | YES |
| 'root'@'::1' | def | INSERT | YES |
| 'root'@'::1' | def | UPDATE | YES |
| 'root'@'::1' | def | DELETE | YES |
| 'root'@'::1' | def | CREATE | YES |
| 'root'@'::1' | def | DROP | YES |
| 'root'@'::1' | def | RELOAD | YES |
| 'root'@'::1' | def | SHUTDOWN | YES |
| 'root'@'::1' | def | PROCESS | YES |
| 'root'@'::1' | def | FILE | YES |
| 'root'@'::1' | def | REFERENCES | YES |
| 'root'@'::1' | def | INDEX | YES |
| 'root'@'::1' | def | ALTER | YES |
| 'root'@'::1' | def | SHOW DATABASES | YES |
| 'root'@'::1' | def | SUPER | YES |
| 'root'@'::1' | def | CREATE TEMPORARY TABLES | YES |
| 'root'@'::1' | def | LOCK TABLES | YES |
| 'root'@'::1' | def | EXECUTE | YES |
| 'root'@'::1' | def | REPLICATION SLAVE | YES |
| 'root'@'::1' | def | REPLICATION CLIENT | YES |
| 'root'@'::1' | def | CREATE VIEW | YES |
| 'root'@'::1' | def | SHOW VIEW | YES |
| 'root'@'::1' | def | CREATE ROUTINE | YES |
| 'root'@'::1' | def | ALTER ROUTINE | YES |
| 'root'@'::1' | def | CREATE USER | YES |
| 'root'@'::1' | def | EVENT | YES |
| 'root'@'::1' | def | TRIGGER | YES |
| 'root'@'::1' | def | CREATE TABLESPACE | YES |
| 'pma'@'localhost' | def | USAGE | NO |
| ''@'localhost' | def | USAGE | NO |
+--------------------+---------------+-------------------------+--------------+
86 rows in set (0.01 sec)

MariaDB [information_schema]> select curdate();


+------------+
| curdate() |
+------------+
| 2018-11-30 |
+------------+
1 row in set (0.00 sec)

MariaDB [information_schema]> select curtime();


+-----------+
| curtime() |
+-----------+
| 08:42:12 |
+-----------+
1 row in set (0.00 sec)

MariaDB [information_schema]> select now();


+---------------------+
| now() |
+---------------------+
| 2018-11-30 08:42:16 |
+---------------------+
1 row in set (0.00 sec)

MariaDB [information_schema]> show variables where Variable_name = 'hostname';


+---------------+------------+
| Variable_name | Value |
+---------------+------------+
| hostname | INFO1-PC22 |
+---------------+------------+
1 row in set (0.02 sec)

MariaDB [information_schema]> select year(now());


+-------------+
| year(now()) |
+-------------+
| 2018 |
+-------------+
1 row in set (0.00 sec)

MariaDB [information_schema]> select year('1969-10-24');


+--------------------+
| year('1969-10-24') |
+--------------------+
| 1969 |
+--------------------+
1 row in set (0.00 sec)

MariaDB [information_schema]> select month('1969-10-24');


+---------------------+
| month('1969-10-24') |
+---------------------+
| 10 |
+---------------------+
1 row in set (0.00 sec)

MariaDB [information_schema]> select day('1969-10-24');


+-------------------+
| day('1969-10-24') |
+-------------------+
| 24 |
+-------------------+
1 row in set (0.00 sec)

MariaDB [information_schema]> select monthname('1969-10-24');


+-------------------------+
| monthname('1969-10-24') |
+-------------------------+
| October |
+-------------------------+
1 row in set (0.02 sec)

MariaDB [information_schema]> select * from ENGINES;


+--------------------+---------
+----------------------------------------------------------------------------------
----------------+--------------+------+------------+
| ENGINE | SUPPORT | COMMENT
| TRANSACTIONS | XA | SAVEPOINTS |
+--------------------+---------
+----------------------------------------------------------------------------------
----------------+--------------+------+------------+
| CSV | YES | Stores tables as CSV files
| NO | NO | NO |
| InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level
locking, foreign keys and encryption for tables | YES | YES | YES
|
| MEMORY | YES | Hash based, stored in memory, useful for temporary
tables | NO | NO | NO |
| MyISAM | YES | Non-transactional engine with good performance and
small data footprint | NO | NO | NO |
| MRG_MyISAM | YES | Collection of identical MyISAM tables
| NO | NO | NO |
| Aria | YES | Crash-safe tables with MyISAM heritage
| NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema
| NO | NO | NO |
| SEQUENCE | YES | Generated tables filled with sequential values
| YES | NO | YES |
+--------------------+---------
+----------------------------------------------------------------------------------
----------------+--------------+------+------------+
8 rows in set (0.02 sec)

MariaDB [information_schema]> select count(ENGINE) AS motore FROM engines;


+--------+
| motore |
+--------+
| 8 |
+--------+
1 row in set (0.01 sec)

MariaDB [(none)]> -- per loggare su file : \T c:\Users\ecc...


MariaDB [(none)]> select dayofweek('1999-12-25') as "giorno della settimana";
+------------------------+
| giorno della settimana |
+------------------------+
| 7 |
+------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select dayofweek(now()) as "giorno della settimana";


+------------------------+
| giorno della settimana |
+------------------------+
| 6 |
+------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select dayname(now()) as "giorno della settimana";


+------------------------+
| giorno della settimana |
+------------------------+
| Friday |
+------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select datediff(now(), '2000-09-15') as "giorni di vita";


+----------------+
| giorni di vita |
+----------------+
| 6650 |
+----------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select adddate(now(), 10000) as "fra 10000 giorni sara' il";
+---------------------------+
| fra 10000 giorni sara' il |
+---------------------------+
| 2046-04-17 08:56:58 |
+---------------------------+
1 row in set (0.01 sec)

MariaDB [(none)]> select addtime(now(), 600) as "che ore sono fra 600 secondi";
+------------------------------+
| che ore sono fra 600 secondi |
+------------------------------+
| 2018-11-30 09:06:20 |
+------------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select curtime() as "che ore sono adesso";


+---------------------+
| che ore sono adesso |
+---------------------+
| 09:00:55 |
+---------------------+
1 row in set (0.00 sec)
MariaDB [(none)]> select addtime(now(), "10:00:00") as "che ore sono fra 10 ore";
+-------------------------+
| che ore sono fra 10 ore |
+-------------------------+
| 2018-11-30 19:01:40 |
+-------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> help period_add


Name: 'PERIOD_ADD'
Description:
Syntax:
PERIOD_ADD(P,N)

Adds N months to period P (in the format YYMM or YYYYMM). Returns a


value in the format YYYYMM. Note that the period argument P is not a
date value.

URL: http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html

Examples:
mysql> SELECT PERIOD_ADD(200801,2);
-> 200803

MariaDB [(none)]> select sec_to_time(1543564923);


+-------------------------+
| sec_to_time(1543564923) |
+-------------------------+
| 838:59:59 |
+-------------------------+
1 row in set, 1 warning (0.00 sec)

MariaDB [(none)]> select sec_to_time(15435);


+--------------------+
| sec_to_time(15435) |
+--------------------+
| 04:17:15 |
+--------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select sec_to_time(10000);


+--------------------+
| sec_to_time(10000) |
+--------------------+
| 02:46:40 |
+--------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select sec_to_time(3600)


-> ;
+-------------------+
| sec_to_time(3600) |
+-------------------+
| 01:00:00 |
+-------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select time_to_sec(now());


+--------------------+
| time_to_sec(now()) |
+--------------------+
| 32861 |
+--------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select time_to_sec(curtime());


+------------------------+
| time_to_sec(curtime()) |
+------------------------+
| 32871 |
+------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select time_to_sec("03:00:00");


+-------------------------+
| time_to_sec("03:00:00") |
+-------------------------+
| 10800 |
+-------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select right("Bonora", 2);


+--------------------+
| right("Bonora", 2) |
+--------------------+
| ra |
+--------------------+
1 row in set (0.02 sec)

MariaDB [(none)]> select left("Bonora", 2);


+-------------------+
| left("Bonora", 2) |
+-------------------+
| Bo |
+-------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select right(curdate(), 2);


+---------------------+
| right(curdate(), 2) |
+---------------------+
| 30 |
+---------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select substr(curdate(), 6, 2) as "oggi � il giorno";


+------------------+
| oggi � il giorno |
+------------------+
| 11 |
+------------------+
1 row in set (0.00 sec)
MariaDB [(none)]> -- sottostringa lunga due caratteri che parte dal sesto carattere

MariaDB [(none)]> -- l'indice del carattere parte da 1, non da 0


MariaDB [(none)]> -- primo carattere ha indice 1

MariaDB [(none)]> select replace("ciao, mi chiamo mario, ho 32 anni e soffro di


amnesia. Ogni giorno
"> mi addormento mentre leggo il mio libro, arrivo fino al punto in cui...ciao,
sono mario, ho 32 anni
"> ", "mario", "bepi");
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------+
| replace("ciao, mi chiamo mario, ho 32 anni e soffro di amnesia. Ogni giorno
mi addormento mentre leggo il mio libro, arrivo fino al punto in cui...ciao, sono
mario, ho 32 anni
", "mario", "bepi") |
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------+
| ciao, mi chiamo bepi, ho 32 anni e soffro di amnesia. Ogni giorno
mi addormento mentre leggo il mio libro, arrivo fino al punto in cui...ciao, sono
bepi, ho 32 anni
|
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select repeat("mi me ciamo luigino e me piase un po' el vino|",


3);
+----------------------------------------------------------------------------------
----------------------------------------------------------+
| repeat("mi me ciamo luigino e me piase un po' el vino|", 3)
|
+----------------------------------------------------------------------------------
----------------------------------------------------------+
| mi me ciamo luigino e me piase un po' el vino|mi me ciamo luigino e me piase un
po' el vino|mi me ciamo luigino e me piase un po' el vino| |
+----------------------------------------------------------------------------------
----------------------------------------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select truncate(34,2343423);


+----------------------+
| truncate(34,2343423) |
+----------------------+
| 34 |
+----------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select ascii('a');


+------------+
| ascii('a') |
+------------+
| 97 |
+------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select ascii('A');


+------------+
| ascii('A') |
+------------+
| 65 |
+------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select char_length("miastringa");


+---------------------------+
| char_length("miastringa") |
+---------------------------+
| 10 |
+---------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> -- ora mi sloggo dal file usando '\t'


MariaDB [(none)]> \t

You might also like