Unsupported Screen Size: The viewport size is too small for the theme to render properly.

Drop And Create Table – New Mysql User

forums forums SQLyog Using SQLyog Drop And Create Table – New Mysql User

  • This topic is empty.
Viewing 4 reply threads
  • Author
    Posts
    • #9422
      rtk
      Member

      When I try and create a table that already exists I get “Error Code : 1050

      Table 'products' already exists”.

      Is there a way to create the table and force it to overwrite if the table already exists?

      I've tried this series in my query

      DROP TABLE PRODUCTS

      CREATE TABLE PRODUCTS

      SELECT …

      but I get…

      Error Code : 1064

      You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE PRODUCTS

      Thanks

      Russ

    • #20144
      peterlaursen
      Participant
      Quote:
      I've tried this series in my query

      DROP TABLE PRODUCTS

      CREATE TABLE PRODUCTS

      SELECT …

      First: If you have more queries they should be divided with “;” (semicolon)

      Next: A new table must have at least one column. You could write then (just an example):

      Quote:
      drop table products;

      create table products (`id` bigint  NOT NULL AUTO_INCREMENT ,  `t` varchar (50)  NULL  , PRIMARY KEY ( `id` )  );

      select ….

      But why don't you use the GUI ?

      1) Right.click a table .. choose 'drop table'

      2) Right-click a database .. choose 'create table' SQLyog then generates the SQL needed. You can view it in HISTORY-pane

    • #20145
      peterlaursen
      Participant

      Besides ..

      You can also ALTER TABLE …

      Then existing data are kept (unless you drop the column)

    • #20146
      rtk
      Member

      I'm using the SELECT statement to create the data.

      I don't want to use the GUI because what I want to happen without user input at night is this…

      1/Import my ODBC tables automatically (figured this out)

      2/Create a table using a select statement automatically (almost there except for this problem)

      3/Export the new table to my website MYSQL server.

      If I seperate the drop table statment from my create table statement with a ';' it stops the query after the “drop table” and does not create the new table from the following select statement.

      If I run the drop table statement and the create table select… individually in separate queries they work fine.

      ?

    • #20147
      peterlaursen
      Participant
      Quote:
      If I seperate the drop table statment from my create table statement with a ';' it stops the query after the “drop table” and does not create the new table from the following select statement.

      Ok – there are two possibilities:

      1) to execute 'current query' (single arrow icon or keyboard shortcut: F5)

      2) to execute 'all queries' (double arrow icon or keyboard shortcut: Shift + F5)

      Check program help .. keyboard shortcuts

Viewing 4 reply threads
  • You must be logged in to reply to this topic.