helpdesk
helpdesk

Reputation: 2084

MySQL CREATE TABLE command

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]

Upvotes: 1

Views: 1547

Answers (1)

aleroot
aleroot

Reputation: 72676

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.

Upvotes: 4

Related Questions