How to Create a Table in Oracle with name abc@gma开发者_开发技巧il.com
I tried doing CREATE TABLE abc@gmail.com(..)
but this gives me error so i was looking for some other way of doing it
Either:
Put double-quotes around your table name:
CREATE TABLE "abc@gmail.com" ...
Don't put special characters in your table names.
Future users of your database will thank you profusely if you choose option 2.
I think is a not good way to place @.
charactes in name of a table.
I think is a not good way to create each table per one email user. Propably you have big database design problem and you trying to find solution where it not exists.
Think about database emails
, table users
there each user have unique ID
and username
and domain
in other column. On ID
column you have create index, then you have some thing to find and add relationship of user instance in other tables.
From http://ora-903.ora-code.com/:
ORA-00903: invalid table name
Cause: A table or cluster name is invalid or does not exist. This message is also issued if an invalid cluster name or no cluster name is specified in an ALTER CLUSTER or DROP CLUSTER statement.
Action: Check spelling. A valid table name or cluster name must begin with a letter and may contain only alphanumeric characters and the special characters $, _, and #. The name must be less than or equal to 30 characters and cannot be a reserved word.
Martin and CanSpice have pointed out that it's technically possible, but, yeah... you're asking for plenty of trouble with this approach. And why (on earth) would you name a table after an email address in the first place? I'd be fascinated to know.
To use non standard characters in identifiers you can delimit with double quotes.
CREATE TABLE "abc@gmail.com"(a int);
NB: Some of the discussion on this question reminded me of a simple talk article. I just tested and this is possible in Oracle as well.
CREATE TABLE "╚╦╩╗" ( "└┬┴┐" nvarchar2(10));
INSERT INTO "╚╦╩╗" VALUES ( '└┬┴┐' );
SELECT * FROM "╚╦╩╗";
Note I am not suggesting that anybody actually does this.
What an odd name for a table.
I don't have access to an Oracle instance to find out which error you are getting, but it will refer to the third point below:
- The table name must begin with a letter.
- The table name can not be longer than 30 characters.
- The table name must be made up of alphanumeric characters or the following special characters: $, _, and #.
- The table name can not be a reserved word.
That email address looks like it should be in the table, as data.
Have a think about what you are going to store in the table and that should give you a more appropriate table name.
If you must, you could always name the table "abc_at_gmail.com" and get on with it.
I believe the at-sign means "link to another database" in Oracle. You're out of luck in preserving the e-mail address.
If you really need multiple e-mail addresses, why wouldn't you create a users table and have multiple rows, one per e-mail address, and make e-mail address a unique index on the table? Your design idea must be breaking some normalization rule.
精彩评论