标签:delect title 组成 ast fse mon database delete sts
SELECT column_1, column_2, ... FROM table_1 [INNER | LEFT |RIGHT] JOIN table_2 ON conditions WHERE conditions GROUP BY column_1 HAVING group_conditions ORDER BY column_1 LIMIT offset, length;
SELECT lastname,firstname,jobtitle FROM employees;
SELECT * FROM employees;
SELECT lastname,firstname,jobtitle FROM employees WHERE jobtitle = ‘Sales Rep‘;
SELECT lastname,firstname,jobtitle FROM employees WHERE jobtitle=‘Sales Rep‘ AND officeCode = 1;
INSERT INTO tasks(subject,start_date,end_date,description) VALUES(‘Learn MySQL INSERT‘,‘2017-11-27‘,‘2017-11-27‘,‘start learning..‘);
INSERT INTO tasks_bak SELECT * FROM tasks;
UPDATE employees SET email=‘mary.new@yiibai.com‘ WHERE employeeNumber = 1056;
UPDATE employees SET email=‘mary@yiibai.com‘,lastname=‘Hill‘ WHERE employeeNumber = 1056;
UPDATE customers SET salesRepEmployeeNumber = (SELECT employeeNumber FROM employees WHERE jobtitle=‘Sales Rep‘ ORDER BY RAND() LIMIT 1) WHERE salesRepEmployeeNumber IS NULL;
DELETE FROM tasks WHERE task_id=3;
CREATE DATABASE IF NOT EXISTS mytest;
DROP DATABASE IF EXISTS mytest;
CREATE TABLE [IF NOT EXISTS] table_name( column_list ) engine=table_type;
column_name data_type[size] [NOT NULL|NULL] [DEFAULT value] [AUTO_INCREMENT] PRIMARY KEY (col1,col2,...)
CREATE TABLE IF NOT EXISTS tasks ( task_id INT(11) NOT NULL AUTO_INCREMENT, subject VARCHAR(45) DEFAULT NULL, start_date DATE DEFAULT NULL, end_date DATE DEFAULT NULL, description VARCHAR(200) DEFAULT NULL, PRIMARY KEY (task_id) ) ENGINE=InnoDB;
ALTER TABLE table_name action1[,action2,…]
ALTER TABLE mytest ADD COLUMN task_id INT(11) NOT NULL;
ALTER TABLE mytest CHANGE COLUMN task_id task_id INT(10) NOT NULL AUTO_INCREMENT; ALTER TABLE mytest ADD COLUMN task_id INT(11) NOT NULL; ALTER TABLE tasks RENAME TO work_items;
标签:delect title 组成 ast fse mon database delete sts
原文地址:http://www.cnblogs.com/kaiho/p/7911074.html