mySQL commands
mysql> show databases;
shows databases
mysql> use cat_db;
Shows cat database
mysql> show tables;
mysql> SELECT DATABASE();
shows current database
mysql> describe cats;
Shows table info
mysql> show columns in cats;
CREATE TABLE students (
id INTEGER(11) AUTO_INCREMENT NOT NULL,
name VARCHAR(30) NOT NULL,
age INTEGER(10));
SQL PRIMARY KEY Constraint on CREATE TABLE
CREATE TABLE students(
id INTEGER(11) AUTO_INCREMENT NOT NULL,
name VARCHAR(30) NOT NULL,
age INTEGER(10),
location VARCHAR(30) NOT NULL,
PRIMARY KEY(id)
);
INSERT INTO tbl_name
(a,b,c)
VALUES
(1,2,3),
(4,5,6),
(7,8,9);
mysql> select * from students where id in (2,3);
Updating records: UPDATE [table] SET [column] = '[updated-value]' WHERE [column] = [value];
Update students set age = 22;
Updates all