SQL

SQL Important CMD

Insert data using CSV file

LOAD DATA LOCAL INFILE '/var/www/html/csv_file/your_csv_file.csv' IGNORE
INTO TABLE my_table
fields terminated BY ','
lines terminated BY '\n'
IGNORE 1 ROWS
(@col1, @col2, @col3,@col4,,@col5)
SET col1= @col1, col2= @col2, col3= @col3, col4= @col4, col5= @col5

Update data based on another table

UPDATE table_1 
INNER JOIN table_2 
ON table_1.internal_id = table_2.internal_id 
SET table_1.city = table_2.city, 
table_1.state = table_2.state
WHERE table_2.internal_id = table_2.internal_id

Connect your DB using CMD:

mysql -h host_name -u db_user_name -p db_name

Database backup using CMD:

mysqldump -h host_name -u db_user_name -p db_name table_name > /folder/table_name.sql

Leave a Reply

Your email address will not be published. Required fields are marked *