Skip to content

How to force export function use backtick (`) in create table syntax? #629

Closed

Description

@lvbeck

Hi,

I need export my SQLite database to sql file with MySQL compatibility, hence I want to use always backtick (`) for CREATE TABLE syntax. For example:

CREATE TABLE `Table1` (`ID` INTEGER,`Name` TEXT);

however, in the exported sql, the create statement contains backtick (`) as well as double quote (") and single quote (') , which seems to be a random behavior.

for example I have a table with schema:

CREATE TABLE `Source` (`Source_ID` INTEGER, `Name_Source` TEXT);

if I export this table, it become to:

CREATE TABLE "Source" (`Source_ID`  INTEGER, `Name_Source` TEXT)

or

CREATE TABLE 'Source' ('Source_ID' INTEGER, 'Name_Source' TEXT);

And it's also unpredictable in the CREATE INDEX statements:
in this case I want no quote around the columns like:

CREATE INDEX Source_Source_ID ON Source (Source_ID);

but the exported sql is:

CREATE INDEX 'Source_Source_ID' ON 'Source' ('Source_ID' );

So when I import the sql to MYSQL database, I got syntax errors

Activity

  1. added
    bugConfirmed bugs or reports that are very likely to be bugs.
    on Jun 21, 2016
  2. justinclift commented on Jun 21, 2016

    @justinclift
    Member

    Interesting. This shouldn't be too hard to implement. 😄

  3. lvbeck commented on Jun 21, 2016

    @lvbeck
    Author

    @justinclift it would be great to have user defined quote character for export

  4. added and removed
    bugConfirmed bugs or reports that are very likely to be bugs.
    on Jun 21, 2016
  5. MKleusberg commented on Jan 27, 2017

    @MKleusberg
    Member

    This should really be fixed I think 😃 @lvbeck Can you test the latest version (3.9.1 or the nightly builds, whatever you prefer)? I'm pretty sure we quote all names using the ` quotes.

  6. MKleusberg commented on Jan 27, 2017

    @MKleusberg
    Member

    Oh no I'm sorry, I was wrong. For the SQL dump we take the CREATE statement as is. This means it's quoted in the SQL export just like it's quoted in the original database. But I can fix that 😃

  7. MKleusberg commented on Jan 27, 2017

    @MKleusberg
    Member

    @lvbeck Sorry for the confusion 😃 If you're still interested in this, can you test tomorrow's nightly build and see if it's improving the situation for you? For triggers and views we don't have a chance to do this (yet) but tables and indices should be much better now.

  8. lvbeck commented on Jan 27, 2017

    @lvbeck
    Author

    @MKleusberg it would be great if you can implement this feature(tables and indices are enough for me), however I am not able to test the nightly build this week, I will check later ASAP, thank you.

  9. MKleusberg commented on Jan 27, 2017

    @MKleusberg
    Member

    No worries 😃 Just test it whenever you have the time for it. Thank you for your effort! 😃

  10. justinclift commented on Mar 3, 2017

    @justinclift
    Member

    @lvbeck ping?

  11. lvbeck commented on Mar 3, 2017

    @lvbeck
    Author

    @justinclift @MKleusberg thanks, it's now working! I will close the issue

  12. justinclift commented on Mar 3, 2017

    @justinclift
    Member

    @lvbeck Excellent, thanks for checking and letting us know. 😄

  13. lvbeck commented on May 8, 2017

    @lvbeck
    Author

    @MKleusberg just another tiny feature request, could you please add:

    DROP TABLE IF EXISTS `Tablename`;
    

    before CREATE TABLE syntax?
    This would be very helpful if the table existed in database. Thank you!

  14. reopened this on May 8, 2017
  15. MKleusberg commented on May 12, 2017

    @MKleusberg
    Member

    @lvbeck Sure, no problem 😃 I've added an additional option to the Export SQL dialog to enable this feature. So you'll need to set it up like this:
    spectacle lh5631
    Can you download the next nightly build (tomorrow) and check if it's working for you as expected?

  16. lvbeck commented on May 15, 2017

    @lvbeck
    Author

    @MKleusberg I tested nightly build "DB Browser for SQLite-2017-05-15-win64.exe", it work exactly as expected, thank you for the amazing work!

  17. justinclift commented on May 15, 2017

    @justinclift
    Member

    Awesome. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions