programing

mysqldump with --where clause is not working

telebox 2023. 9. 19. 21:00
반응형

mysqldump with --where clause is not working

 mysqldump -t -u root -p  mytestdb mytable --where=datetime LIKE '2014-09%'

This is what I am doing and it returns:

mysqldump: Couldn't find table: "LIKE"

열이 있는 모든 행을 반환하려고 합니다.datetimelike 2014-09"9월의 모든 행"을 의미합니다.

You may need to use quotes:

mysqldump -t -u root -p  mytestdb mytable --where="datetime LIKE '2014-09%'"

Selecting dates using LIKE is not a good idea. I saw this method in one project. This causes huge DBMS load and slow system operation as no index by this table column used.

If you need to select date range use between:

where datetime between '2014-09-01' and '2014-09-30 23:59:59'

사용할 때 답변이 아니라 공지사항일 뿐입니다.mysqldump자동으로 추가됩니다.DROP TABLE그리고.CREATE TABLE내보내기 파일에 추가를 원하지 않는 경우--skip-add-drop-table그리고.--no-create-info다음과 같은 명령을 받습니다.

mysqldump -u root-p database_name table_name --skip-add-drop-table --no-create-info > export.sql

You missed "" for where clause . datetime column name datetime is not recommended. It is a data type as well.

mysqldump -u root -p mytestdb mytable --where="datetime LIKE '2014-09%'
" > mytable.sql;

After executing the command a prompt will ask for MySQL password. then check your current folder for generated mystable.sql

ReferenceURL : https://stackoverflow.com/questions/26261670/mysqldump-with-where-clause-is-not-working

반응형