Erro ao Criar tabela no Banco [RESOLVIDO]

0 respostas
Maureli

Estou com um problema ao criar essa tabela com chave estrangeira:

Tabela - box
Colunas - box_id / numero / vago

Tabela - cliente
Colunas - cli_id / nome /cpf

try{
             DatabaseMetaData dbm = conn.getMetaData();
            // check if "employee" table is there
            ResultSet tables = dbm.getTables(null, null, "cliente", null);
            if (tables.next()) {
                System.out.print("A tabela já existe ");
            } else {
            String sql = ("CREATE TABLE cliente(cli_id int NOT NULL PRIMARY KEY, nome varchar(50),cfp int,"
                    + "box_Id int FOREIGN KEY REFERENCES box(box_id))");
                  
            PreparedStatement stmt = conn.prepareStatement(sql);
            stmt.executeUpdate();
            }

[color=red]ERRO - erro de sintaxe em ou próximo a "FOREIGN"[/color]

Criado 8 de fevereiro de 2011
Respostas 0
Participantes 1