HelloWorld


Zhikang Li's personal blog


mysql basic usage

service

  • net stop MySQL57
  • net start MySQL57

shell

open

  • mysql -u root -p
  • ps: Root

in shell

  • USE db
  • QUIT

utility

  • show tables;
  • show databases;
  • describe tb;

Load data

  1. mysql> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;

    • txt format: Whistler Gwen bird \N 1997-12-09 \N
    • \N represent NULL values
    • values seperated by tabs
  2. mysql> INSERT INTO pet VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);

set primary key

  • alter table tb add primary key (col_name)

create Table

  1. create table db1.tb like db2.tb
  2. create table tb

delete all things in a table

  • TRUNCATE TABLE tablename
  • DELETE FROM tablename

X/A

  • xa rollback xid
    • xa rollback 'data[0:gtrid_length]','data[gtrid_length:-1]',formatID
  • xa recover