blob: 8f6455611edd17d6c215d28e342f822928bd07f2 [file] [log] [blame]
[MySQL|http://www.mysql.com] is an open-source RDBMS that's very easy to set up and use. We sometimes use MySQL in the development phase of projects when we need a database we can administer ourselves because of frequent schema changes. [Hypersonic] is another nice RDBMS for this purpose. Recently, getting an [Oracle] instance made and administering it ourselves has become easier, so we're relying less on MySQL.
h1. Reference
Here's a quick list of common MySQL commands (most of these are just plain SQL, actually).
List of databases:
{{SHOW DATABASES;}}
Switch to database:
{{USE dbname;}}
List of tables in database:
{{SHOW TABLES;}}
Table details:
{{DESCRIBE tblname;}}
Create database:
{{CREATE DATABASE dbname;}}
Grant privileges on database:
{{GRANT ALL ON dbname.* TO username;}}
Add table:
{{CREATE TABLE tblname (colname type, colname type, ...);}}
Remove table:
{{DROP TABLE tblname;}}
Add column:
{{ALTER TABLE tblname ADD colname type \[NOT NULL\] \[DEFAULT value\];}}
Remove column:
{{ALTER TABLE tblname DROP colname;}}
Rename column:
{{ALTER TABLE tblname CHANGE colname newcolname (same type);}}
Insert row:
{{INSERT tblname (colname,...) VALUES (expr,...);}}
Update rows:
{{UPDATE tblname SET colname=expr, ... \[WHERE where_expr\];}}
Remove rows:
{{DELETE FROM tblname \[WHERE where_expr\];}}
Compare with NULL:
{{colname IS \[NOT\] NULL}}