Help in Mysql Phpmyadmin How to insert a table in a database?

Asked

Viewed 276 times

0

How do I insert a table into a abanco ? I am a beginner mysql user and beginner in the world of programming.

I made the following code:

INSERT INTO banco1(

CREATE TABLE Cliente (
    id INT NOT NULL AUTO_INCREMENT
    nome varchar(60)NOT NULL DEFAULT vazio, 
    sexo ENUM('M','F'),
    data_de_nascimento date,
    limite_de_credito decimal(9,2),
    cidade varchar(50),
    bairro varchar(50)
    PRIMARY KEY(id), 
    INDEX(nome) ))
    ENGINE=INNODB   Charset= utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT;

I got the following error:

Error Static analysis: 2 errors were found during analysis.

Palavra-chave inesperada. (near "ENGINE" at position 311)
Unrecognized statement type. (near "ENGINE" at position 311)

Comando SQL: 
INSERT INTO banco1( CREATE TABLE Cliente ( id INT NOT NULL AUTO_INCREMENT nome varchar(60)NOT NULL DEFAULT vazio, sexo ENUM('M','F'), data_de_nascimento date, limite_de_credito decimal(9,2), cidade varchar(50), bairro varchar(50) PRIMARY KEY(id), INDEX(nome) )) ENGINE=INNODB Charset= utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT 
Mensagens do MySQL :  
#1046 - Nenhum banco de dados foi selecionado
  • Click on the database and then yes execute the query.

  • I need to do this by the code. It is study activity. Then I need to know how you do for the case of any discursive evidence during the year.

  • Before the Insert puts one use nome do banco;

  • Good guy ! Thank you!

1 answer

0


The INSERT is used to insert data into tables, not tables into databases. If you want to use a database use the command USE.

Instead of:

    INSERT INTO banco1 ... ;

Exchange for:

    USE banco1; 
    CREATE TABLE ... ;
  • I got it. I got it right there the ";" and the "USE"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.