Professional Documents
Culture Documents
Mysql Cmds
Mysql Cmds
testDB - login to mysql - see which user is logged in - see which databases currently exist on server - see which database is currently selected - Use the database called database - create a database called testDB
SHOW TABLES;
CREATE TABLE test_table (name VARCHAR(20), id INT); - to create a table called test_table with columns name and id DESCRIBE test_table; - see table design
LOAD DATA LOCAL INFILE /path/input.txt INTO TABLE test_table; - to populate a table using a text file (tab separated, \N for null field) LOAD LINES TERMINATED BY \r\n ; - to populate table if text file created on windows where \r\n end lines
INSERT INTO test_table VALUES ( Jack , 58976); - add a new record into a table DELETE FROM test_table; - empty the table
UPDATE test_table SET id = 12345 WHERE name = Jack ; - fix a record To pull information from a table: SELECT what_to_select FROM which_table WHERE conditions_to_satisfy; - what_to_select can be a list of columns, or * for all - WHERE is optional SELECT * FROM test_table; - retrieves everything from a table - order by descending order - order by ascending order
SELECT * FROM test_table ORDER BY test_id DESC; SELECT * FROM test_table ORDER BY test_id ASC;