This page lists the most important SQL statements and contains links to their documentation pages. If you need a basic tutorial on how to use the MariaDB database server and how to execute simple commands, see A MariaDB Primer.
Also see Common MariaDB Queries for examples of commonly-used queries.
CREATE DATABASE mydb; USE mydb; CREATE TABLE mytable ( id INT PRIMARY KEY, name VARCHAR(20) ); INSERT INTO mytable VALUES ( 1, 'Will' ); INSERT INTO mytable VALUES ( 2, 'Marry' ); INSERT INTO mytable VALUES ( 3, 'Dean' ); SELECT id, name FROM mytable WHERE id = 1; UPDATE mytable SET name = 'Willy' WHERE id = 1; SELECT id, name FROM mytable; DELETE FROM mytable WHERE id = 1; SELECT id, name FROM mytable; DROP DATABASE mydb; SELECT count(1) from mytable; gives the number of records in the table
The first version of this article was copied, with permission, from http://hashmysql.org/wiki/Basic_SQL_Statements on 2012-10-05.
© 2023 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/basic-sql-statements/