List:General Discussion« Previous MessageNext Message »
From:Jules Bean Date:May 1 1999 7:23pm
Subject:Re: creating a database
View as plain text  
Daniel Lacal wrote:
> 
> I'm new in this world, and I've done three scripts to create de database with tables
> and some data, but it doesn't works.
> The only thing that works is the script that drops and creates de database:
> 
> the script's name is: visitas_setup.sh, and contains:

[script looked OK to me]

> Other file is created like this: estructura_visitas.mysql
[..]
> #----------------------------------------------------------------------#
> #                          TABLA DE ACCESOS                            #
> #----------------------------------------------------------------------#
>   CREATE TABLE accesos (
>  NumAccesos TINYINT UNSIGNED ,
>  TipoAcceso VARCHAR (15) NOT NULL PRIMARY KEY );
> 
>   INSERT INTO accesos VALUES ("Yahoo" ,0);
>   INSERT INTO accesos VALUES ("Magallanes", 0);
>   INSERT INTO accesos VALUES ("Ozu", 0);
>   INSERT INTO accesos VALUES ("Ole", 0);
>   INSERT INTO accesos VALUES ("Directo", 0);
>   INSERT INTO accesos VALUES ("Otros", 0);

Here is certainly a problem.  When you INSERT without specify column
names, the order must be as in the create statement.  Since the create
statement has 'NumAccesos' first, you must also do this in your
inserts.  I.e. "....VALUES (0,'Yahoo')".

Note that mysql uses single quotes ' not double quotes " for string
values, too.

It is always best to test SQL statements with the command-line tool
mysql first, since that gives you convenient error messages.

For more information of different kinds of INSERT statement, check the
manual.

Jules

/----------------+-------------------------------+---------------------\
|  Jelibean aka  | jules@stripped         |  6 Evelyn Rd        |
|  Jules aka     |                               |  Richmond, Surrey   |
|  Julian Bean   | jmlb2@stripped        |  TW9 2TF *UK*       |
+----------------+-------------------------------+---------------------+
|  War doesn't demonstrate who's right... just who's left.             |
|  When privacy is outlawed... only the outlaws have privacy.          |
\----------------------------------------------------------------------/
Thread
creating a databaseDaniel Lacal30 Apr
  • Re: creating a databaseJules Bean1 May