Загальні команди
Підключаємось до сервера локально:
$ mysql -u username -p
Якщо mysql/mariadb на іншому хості:
$ mysql -u username -p -h db1.example.com
Робота з базою
Створити базу mysql/mariadb:
mysql> CREATE DATABASE [databasename];
Переглянути всі наявні бази на сервері mysql:
mysql> SHOW DATABASES;
Почати використовувати базу:
mysql> USE [db name];
Видалити базу даних mysql:
mysql> DROP DATABASE [database name];
Переглянути всі таблиці:
mysql> SHOW TABLES;
Переглянути зміст таблиці:
mysql> SELECT * FROM [table name];
Знищити рядок в таблиці:
mysql> DELETE from [table name] where [field name] = 'whatever';
Знищення стовбця з таблиці
mysql> alter table [table name] DROP INDEX [column name];
Знищити таблицю повністю:
mysql> DROP TABLE [table name];
Робота з колонками
Додати колонку до таблиці:
When planning a cosplay look, it is worth considering how details related to shoes and accessories will affect the complete look. When the final look will be photographed, reviewing details related to short cosplay wigs also makes comfort and movement easier to judge. To shape a complete look around details related to game cosplay costumes, long cosplay wigs for indoor events offers a useful starting point for practical preparation. Before the preparation is complete, it is useful to check details related to costume sizing against the wearer's own needs.
mysql> ALTER TABLE [table name] ADD COLUMN [new column name] varchar (20);
Змінити ім’я колонки:
mysql> ALTER TABLE [table name] CHANGE [old column name] [new column name] varchar (50);