Daily Shaarli

All links of one day in a single page.

February 9, 2024

Note: MariaDB create database

Certainly! Below is a simple example of SQL queries for MariaDB:

  1. Creating a Database and Table:

    CREATE DATABASE mydb;
    USE mydb;
    CREATE TABLE mytable (
       id INT PRIMARY KEY,
       name VARCHAR(20)
    );
  2. Inserting Data:

    INSERT INTO mytable VALUES (1, 'Will');
    INSERT INTO mytable VALUES (2, 'Marry');
    INSERT INTO mytable VALUES (3, 'Dean');
  3. Selecting Data:

    SELECT id, name FROM mytable WHERE id = 1;
  4. Updating Data:

    UPDATE mytable SET name = 'Willy' WHERE id = 1;
  5. Deleting Data:

    DELETE FROM mytable WHERE id = 1;
  6. Dropping the Database:

    DROP DATABASE mydb;
  7. Counting Records:

    SELECT COUNT(1) FROM mytable;

Remember to adapt these queries to your specific use case. If you need more advanced queries or have additional requirements, feel free to ask! 😊

Source: MariaDB Knowledge Base ¹..

Origen: Conversación con Bing, 9/2/2024
(1) Basic SQL Queries & SQL Cheat Sheet | MariaDB Knowledge Base. https://mariadb.com/kb/en/basic-sql-statements/.
(2) 20 Basic SQL Query Examples for Beginners: A Complete Overview. https://learnsql.com/blog/basic-sql-query-examples/.
(3) How To Perform Basic Queries in MySQL and MariaDB on a ... - DigitalOcean. https://www.digitalocean.com/community/tutorials/how-to-perform-basic-queries-in-mysql-and-mariadb-on-a-cloud-server.
(4) undefined. http://hashmysql.org/wiki/Basic_SQL_Statements.
(5) MariaDB - Consultas SQL básicas: una hoja de referencia rápida de SQL. https://runebook.dev/es/docs/mariadb/basic-sql-statements/index.
(6) Comandos SQL Básicos - MariaDB Knowledge Base. https://mariadb.com/kb/es/basic-sql-statements/.
(7) es.wikipedia.org. https://es.wikipedia.org/wiki/MariaDB.