วันศุกร์ที่ 30 กันยายน พ.ศ. 2554

mysql commonly use statement

Create table
mysql> CREATE  table if not exists tblname like old_tblname;

INSERT ... SELECT
mysql> INSERT INTO tblname1 SELECT *  from tblname2 where ...;

Empty table
mysql> TRUNCATE table story_longcon_40;

Delete/Drop table
mysql> DROP TABLE tblname

Delete/Drop database
mysql> DROP {DATABASE | SCHEMA} [IF EXISTS] db_name
Optimize Table

mysql> OPTIMIZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE tbl_name [, tbl_nam

Delete binary logs 
This will delete the binary log till master.000080
mysql> purge binary logs to 'master-bin.000081';

Start slave
mysql> START SLAVE [thread_type [, thread_type] ... ]
or
mysql> START SLAVE [SQL_THREAD] UNTIL
MASTER_LOG_FILE = 'log_name', MASTER_LOG_POS = log_pos


ไม่มีความคิดเห็น:

แสดงความคิดเห็น