Results 1 to 8 of 8
  1. #1
    Join Date
    May 2008
    Posts
    4

    Unanswered: can't set column name as date

    I try to create table A, there is one column name is date, datetype also is date,
    the system won't allow me to do that, I am a new Oracle learner, please help.
    thank you in advance.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >the system won't allow me to do that,
    Whatever "that" might be.

    In the future always use CUT & PASTE so we can see exactly what you are doing & how Oracle responds.

    you can NOT use reserved words, such as DATE, as column names.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    May 2008
    Posts
    4
    if I input these, get a error msg:invailid identifier.
    create table store_infor
    (store_name char(50),
    sales float,
    date date);
    ------------------------------
    in order to do the later excise:
    INSERT INTO Store_Information (store_name, Sales, Date)
    VALUES ('Los Angeles', 900, 'Jan-10-1999')

    what should I set the date and datatype for it?

  4. #4
    Join Date
    Apr 2008
    Posts
    28
    Quote Originally Posted by anacedent
    >

    you can NOT use reserved words, such as DATE, as column names.
    They are allowed

    SQL> create table t1 ("Date" date);

    Table created.

    ...however, Oracle discourages the use of reserved words because it has drawbacks, like adding quotes everytime we use the column, confusion...etc.

  5. #5
    Join Date
    May 2008
    Posts
    4

    thank you guys!

    using " " can solve my problem.

  6. #6
    Join Date
    Apr 2008
    Posts
    28
    Yes, but is not a good practice to use reserved words

  7. #7
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Talking

    Quote Originally Posted by Patrick_jinan
    using " " can solve my problem.

    Wrong, in the long run it creates confusion and is BAD practice.

    Better add a prefix or suffix to indicate the nature of the date like:

    START_DATE
    END_DATE
    EFFECTIVE_DATE
    BIRTH_DATE
    DATE_HIRED
    DATE_CHANGED
    ... ETC ...
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  8. #8
    Join Date
    May 2008
    Posts
    4

    thank you for the tips.

    [QUOTE=LKBrwn_DBA]
    Wrong, in the long run it creates confusion and is BAD practice.

    oh....I better remember it from the begining..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •