1

I am new to MySQL commands. please, I tried creating a table using the MAMP MySQL editor and I got an error #1046 No database selected..Below is the simple code:

[code]

  CREATE TABLE EMPLOYEE_TABLE AS:
  (SSN              NUMBER(9)        NOT NULL,
   LAST_NAME        VARCHAR2(20)     NOT NULL,
   FIRST_NAME       VARCHAR2(20)     NOT NULL,
   MIDDLE_NAME      VARCHAR2(20)     NOT NULL,
   ST ADDRESS       VARCHARS2(20)    NOT NULL,
   CITY             CHAR(20)         NOT NULL,
   STATE            CHAR(2)          NOT NULL,
   ZIP              NUMBER(4)        NOT NULL,
   DATE_HIRED       DATE)
   STORAGE(INITIAL    3K, 
   NEXT               1K)
[/code]
6
  • 2
    USE <your database name>.You are creating a table in nowhere. Commented Apr 8, 2012 at 20:24
  • thanks alot but now i have another challenge. how do i know what manual that corresponds to my SQL server version? I am writing the syntaxes on MAMP mysql Editor Commented Apr 8, 2012 at 20:29
  • 1
    Type \s at the MySQL prompt. In practice I think recent installations are all version 5.5 right now (and in most cases any documentation written for version 5 will be fine). Commented Apr 8, 2012 at 20:32
  • @octern, you mean i type in '\s' into the mysql Editor or terminal? where is the terminal then? please, am sorry this question might be silly but it just shows my mysql level right now Commented Apr 8, 2012 at 20:37
  • Re: SSN NUMBER(9) Not related to the question, but if that is a social security number, do not store it in plain text! Commented Apr 8, 2012 at 20:40

1 Answer 1

4

You have to select the database where you want to insert the table, there are to ways to do it :

  1. Selecting the default database : USE databasename;
  2. Specifying database name before the table in the CREATE TABLE statement : CREATE TABLE DATABASENAME.EMPLOYEE_TABLE ...

Where databasename is the name of your database.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.