SELECT *  FROM table;//查询
SELECT col1,col2  FROM table//查询
SELECT  col1,col2  FROM table WHERE//条件查询
 ALTER TABLE name;
  添加一个字段:ALTER TABLE name ADD
       AFTER | FIRST
  修改字段
  CHANGE old_name new_name col_defination
  MODIFY col_name
  添加索引:
    ADD {INDEX|KEY} [INDEX_NAME][index_type] (col); 
    show indexes from table_name;
  删除字段
  DROP col_name
  删除索引或键
        DROP PRIMARY KEY
        DROP {INDEX|KEY} index_name
  给表重命名:
      RENAME TABLE name1 TO  name2;
 
    删除表:
      DROP TABLE [IF EXISTS] table_name
    插入数据:
     INSERT INTO table_name (col) VALUES (  );
    INSERT INTO table_name SET col=value;
    SELECT LAST_INSERT_ID();
    ALTER TABLE table_name AUTO_INCREMENT=2;设定id从2开始
    成批的插入:
              INSERT INTO table_name (Col) VALUES(''),('')
    REPLACE 如果有一样的,会自动替换掉
    修改数据:
          UPDATE table_name SET COL=value WHERE  LIMIT  n;
    删除数据:
         DELETE FROM table_name
         TRUNCATE TABLE table_name 清空一个表
 
交叉连接SELECT * FROM table1,table2
 外连接
    左外连接
          SELECT * FROM table1 AS A LEFT JOIN table2 AS B ON A.filed1=B.filed2;
    右外连接
          SELECT * FROM table1 AS A RIGHT JOIN table2 AS B ON A.filed1=B.filed2;
    全外连接
         SELECT * FROM table1 AS A  FULL JOIN table2 AS B ON A.filed1=B.filed2;
 内连接
      对称连接:基于等值条件
   SELECT * FROM table1 AS A,table2 AS B WHERE A.filed1=B.filed2; 
联合
  SELECT * FROM table1
  union
   SELECT * FROM table2

自连接
   SELECT * FROM table1 AS A,table1 AS B WHERE A.filed1=B.filed2;