How to clear a SQL Table when Database has a point in its name (bash script)? [duplicate]










-1
















This question already has an answer here:



  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



The script is in /etc/cron.daily.




When I had database name = baseName and the table = tableName, the below script to empty the table worked well :



#!/bin/bash

mysql -u root --password=PASSWD -e "DELETE FROM baseName.tableName"



But I needed to rename the database in baseName.fr.value so I basically modified my script to



#!/bin/bash

mysql -u root --password=PASSWD -e "DELETE FROM baseName.fr.value.tableName"


But I got an You have an error in your SQL syntax, check the manual...




So what's the correct syntax when there's a . in the database name ?










share|improve this question















marked as duplicate by JNevill, mustaccio, Madhur Bhaiya, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 16 '18 at 5:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Try putting square brackets around the full name

    – user1178830
    Nov 15 '18 at 20:33











  • @user1178830 neither [baseName.fr.value.tableName] nor [baseName.fr.value].tableName work :/

    – azro
    Nov 15 '18 at 20:36






  • 1





    @user1178830 That's SQL-Server syntax. MySQL uses backticks.

    – Barmar
    Nov 15 '18 at 20:39















-1
















This question already has an answer here:



  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



The script is in /etc/cron.daily.




When I had database name = baseName and the table = tableName, the below script to empty the table worked well :



#!/bin/bash

mysql -u root --password=PASSWD -e "DELETE FROM baseName.tableName"



But I needed to rename the database in baseName.fr.value so I basically modified my script to



#!/bin/bash

mysql -u root --password=PASSWD -e "DELETE FROM baseName.fr.value.tableName"


But I got an You have an error in your SQL syntax, check the manual...




So what's the correct syntax when there's a . in the database name ?










share|improve this question















marked as duplicate by JNevill, mustaccio, Madhur Bhaiya, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 16 '18 at 5:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Try putting square brackets around the full name

    – user1178830
    Nov 15 '18 at 20:33











  • @user1178830 neither [baseName.fr.value.tableName] nor [baseName.fr.value].tableName work :/

    – azro
    Nov 15 '18 at 20:36






  • 1





    @user1178830 That's SQL-Server syntax. MySQL uses backticks.

    – Barmar
    Nov 15 '18 at 20:39













-1












-1








-1









This question already has an answer here:



  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



The script is in /etc/cron.daily.




When I had database name = baseName and the table = tableName, the below script to empty the table worked well :



#!/bin/bash

mysql -u root --password=PASSWD -e "DELETE FROM baseName.tableName"



But I needed to rename the database in baseName.fr.value so I basically modified my script to



#!/bin/bash

mysql -u root --password=PASSWD -e "DELETE FROM baseName.fr.value.tableName"


But I got an You have an error in your SQL syntax, check the manual...




So what's the correct syntax when there's a . in the database name ?










share|improve this question

















This question already has an answer here:



  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



The script is in /etc/cron.daily.




When I had database name = baseName and the table = tableName, the below script to empty the table worked well :



#!/bin/bash

mysql -u root --password=PASSWD -e "DELETE FROM baseName.tableName"



But I needed to rename the database in baseName.fr.value so I basically modified my script to



#!/bin/bash

mysql -u root --password=PASSWD -e "DELETE FROM baseName.fr.value.tableName"


But I got an You have an error in your SQL syntax, check the manual...




So what's the correct syntax when there's a . in the database name ?





This question already has an answer here:



  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers







mysql sql bash sql-delete






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 20:43









Aaron Bertrand

211k27369407




211k27369407










asked Nov 15 '18 at 20:31









azroazro

11.4k41639




11.4k41639




marked as duplicate by JNevill, mustaccio, Madhur Bhaiya, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 16 '18 at 5:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by JNevill, mustaccio, Madhur Bhaiya, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 16 '18 at 5:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Try putting square brackets around the full name

    – user1178830
    Nov 15 '18 at 20:33











  • @user1178830 neither [baseName.fr.value.tableName] nor [baseName.fr.value].tableName work :/

    – azro
    Nov 15 '18 at 20:36






  • 1





    @user1178830 That's SQL-Server syntax. MySQL uses backticks.

    – Barmar
    Nov 15 '18 at 20:39

















  • Try putting square brackets around the full name

    – user1178830
    Nov 15 '18 at 20:33











  • @user1178830 neither [baseName.fr.value.tableName] nor [baseName.fr.value].tableName work :/

    – azro
    Nov 15 '18 at 20:36






  • 1





    @user1178830 That's SQL-Server syntax. MySQL uses backticks.

    – Barmar
    Nov 15 '18 at 20:39
















Try putting square brackets around the full name

– user1178830
Nov 15 '18 at 20:33





Try putting square brackets around the full name

– user1178830
Nov 15 '18 at 20:33













@user1178830 neither [baseName.fr.value.tableName] nor [baseName.fr.value].tableName work :/

– azro
Nov 15 '18 at 20:36





@user1178830 neither [baseName.fr.value.tableName] nor [baseName.fr.value].tableName work :/

– azro
Nov 15 '18 at 20:36




1




1





@user1178830 That's SQL-Server syntax. MySQL uses backticks.

– Barmar
Nov 15 '18 at 20:39





@user1178830 That's SQL-Server syntax. MySQL uses backticks.

– Barmar
Nov 15 '18 at 20:39












1 Answer
1






active

oldest

votes


















1














In MySQL, you put backticks around database, table, or column names that contain special characters.



mysql -u root --password=PASSWD -e 'DELETE FROM `baseName.fr.value`.tableName'


Note that I changed from double quotes to single quotes, because backticks have special meaning to the shell when used inside double quotes.



See When to use single quotes, double quotes, and back ticks in MySQL and Difference between single and double quotes in Bash.






share|improve this answer































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    In MySQL, you put backticks around database, table, or column names that contain special characters.



    mysql -u root --password=PASSWD -e 'DELETE FROM `baseName.fr.value`.tableName'


    Note that I changed from double quotes to single quotes, because backticks have special meaning to the shell when used inside double quotes.



    See When to use single quotes, double quotes, and back ticks in MySQL and Difference between single and double quotes in Bash.






    share|improve this answer





























      1














      In MySQL, you put backticks around database, table, or column names that contain special characters.



      mysql -u root --password=PASSWD -e 'DELETE FROM `baseName.fr.value`.tableName'


      Note that I changed from double quotes to single quotes, because backticks have special meaning to the shell when used inside double quotes.



      See When to use single quotes, double quotes, and back ticks in MySQL and Difference between single and double quotes in Bash.






      share|improve this answer



























        1












        1








        1







        In MySQL, you put backticks around database, table, or column names that contain special characters.



        mysql -u root --password=PASSWD -e 'DELETE FROM `baseName.fr.value`.tableName'


        Note that I changed from double quotes to single quotes, because backticks have special meaning to the shell when used inside double quotes.



        See When to use single quotes, double quotes, and back ticks in MySQL and Difference between single and double quotes in Bash.






        share|improve this answer















        In MySQL, you put backticks around database, table, or column names that contain special characters.



        mysql -u root --password=PASSWD -e 'DELETE FROM `baseName.fr.value`.tableName'


        Note that I changed from double quotes to single quotes, because backticks have special meaning to the shell when used inside double quotes.



        See When to use single quotes, double quotes, and back ticks in MySQL and Difference between single and double quotes in Bash.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 15 '18 at 20:47









        azro

        11.4k41639




        11.4k41639










        answered Nov 15 '18 at 20:41









        BarmarBarmar

        430k36253354




        430k36253354















            Popular posts from this blog

            27

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            Category:Rhetoric