Korea Hangeul Help Sitemap Calc Link KB
Database / MySql
This page provides a collection of links for database and MySql.

Laptop icon MYSQL COMMANDS
  • mysql> QUIT;
  • mysql> SELECT USER(), VERSION(), SELECT DATE; SELECT DATABASE(), NOW();
  • mysql> SHOW DATABASES; USE db_name;
  • mysql> SHOW TABLES; DESCRIBE tb_name;
  • mysql> CREATE DATABASE db_name;
  • mysql> CREATE TABLE tb1 (var1 VARCHAR(5), var2 INT(2), var3 FLOAT(5,2));
  • mysql> CREATE TABLE tb2 (var1 CHAR(5), var2 DATE);
  • mysql> LOAD DATA LOCAL INFILE "gnp.txt" INTO TABLE tb_name;
  • mysql> INSERT INTO tb VALUES ('Apple','500','2005-03-09',NULL);
  • mysql> UPDATE tb SET var1="Grape" var4="2005-03-09" WHERE id = "12345";
  • mysql> SELECT * FROM tb WHERE income >= 50000;
  • mysql> SELECT * FROM tb WHERE income >= 50000 ORDER by income DESC;
  • mysql> SELECT * FROM tb WHERE id IS NOT NULL;
  • mysql> SELECT id, name FROM tb WHERE (income >= 50000) AND (tax<=1000);
  • mysql> SELECT DISTINCT id, name FROM tb WHERE income >= 50000;
  • mysql> SELECT * FROM tb WHERE income >= 50000 ORDER BY id, name;
  • mysql> SELECT id, name, (income-tax) FROM tb WHERE income >= 50000;
  • mysql> SELECT MAX(income) AS inc_max FROM tb;
  • mysql> SELECT COUNT(*) FROM tb;
  • mysql> SELECT COUNT(*) FROM tb GROUP BY region;
  • mysql> SELECT region, COUNT(*) FROM pet GROUP BY region;
  • mysql> SELECT tb2.name FROM tb1, tb2 WHERE tb1.id=tb2.id;
  • mysql> LOCK TABLES tb READ; UNLOCK TABLES; DROP TABLE tb;