Меню

Ошибка incorrect table name

As soon as you say «I create a table per user» this is an antipattern I call Metadata Tribbles. The problem is that these tables tend to reproduce out of control. 🙂

Instead, you should create one table, with a column for the user’s email as an attribute.

If you use delimited identifiers, SQL table names can contain special characters, or even whitespace, SQL reserved words, international characters, etc. But if you take the back-quotes off, @ and . are not valid characters for an identifier, because it confuses the SQL parser. Think about this: do you use any other programming languages that accept . as a valid character in a variable name or class name?

Other tips:

IP is more easily stored as INT UNSIGNED, and there are functions INET_ATON() and INET_NTOA() to convert an IP address string to and from the binary equivalent. This helps you make sure you don’t accidentally store an invalid IP address. Also you can use bitwise binary operators to do subnet masking operations against an IP address in binary form.

The columns FLD1, FLD2, FLD3 etc. are not descriptive and indicate that you haven’t designed this table sufficiently. You might even need to split this table into a few separate tables to manage multi-valued attributes. But one can’t tell how to do this since your columns are named so abstractly.

ORA-00903: invalid table name error occurs when the table name used to refer to a table in the sql query is invalid or does not exist in the Oracle database. A valid table name must start with a letter and can only contain alphanumeric characters and the special characters $, _, and #. The table’s name cannot contain a reserved keyword. The name must contain no more than 30 characters.If a table name does not meet any of the preceding criteria, Oracle will not recognize it as a table name. Oracle considers the name to be an invalid table name. As a result, the error ORA-00903: invalid table name will be thrown.

The above condition should be followed by the table name. If any of the requirements is not satisfied, the table name should be changed to accommodate the condition. Oracle also allows you to create a table name with a special character or by utilizing reserved keywords. When creating and referring to tables in SQL statements, the table name must be surrounded by double quotation marks.

The valid table name should adhere to the Oracle naming standards listed below.

  • The table name should start with an alphabet.
  • Oracle reserved keywords should not be used in the table name.
  • The table name should not be more than 30 characters long
  • Only alphanumeric characters, as well as the special characters $, _, and #, can be used in the table name.

When the ORA-00903 error occurs

Invalid table names are caused by incorrect naming conventions, a missing of double quotation marks, or incorrect SQL syntax. If you create or refer to a table with an incorrect table name, Oracle will not accept it as a table name. It’s unable to locate the database table. The table name should conform to Oracle naming conventions and be included in the appropriate location in the sql query. If you use the right table name in the correct position in the SQL Statement, the error ORA-00903: invalid table name will be resolved.

CREATE TABLE 1EMP(
id int, 
name VARCHAR2(100)
)
Error starting at line : 4 in command -
CREATE TABLE 1EMP(
id int, 
name VARCHAR2(100)
)
Error report -
ORA-00903: invalid table name
00903. 00000 -  "invalid table name"
*Cause:    
*Action:

Root Cause

The incorrect table name is the result of not following naming conventions, missing double quotation marks, or improper SQL syntax. The database does not recognize the incorrect table name as a table name. Oracle was unable to find the table in the database. As a result, Oracle displays an error message indicating that an incorrect table name was given and could not be found in the database.

Solution 1

The table name should follow the oracle naming conventions. The naming conventions are as follows

  • The table name should starts with an alphabet.
  • The table name should not be an oracle reserved keyword.
  • The table name should not be more than 30 characters
  • The table name can only contain alphanumeric characters as well as the special characters $, _, and #.

Problem A

-- STARTS WITH NUMBER
CREATE TABLE 1EMP(
id int, 
name VARCHAR2(100)
)

ORA-00903: invalid table name
00903. 00000 -  "invalid table name"

Solution A

CREATE TABLE "1EMP"(
id int, 
name VARCHAR2(100)
)
Table "1EMP" created.

Problem B

-- CONTAINS WITH INVALID SPECIAL CHAR
CREATE TABLE !EMP(
id int, 
name VARCHAR2(100)
)

ORA-00903: invalid table name
00903. 00000 -  "invalid table name"

Solution B

CREATE TABLE "!EMP"(
id int, 
name VARCHAR2(100)
)
Table "!EMP" created.

Problem C

--  CONTAINS INVALID RESERVED KEYWORDS
CREATE TABLE SIZE(
id int, 
name VARCHAR2(100)
)

ORA-00903: invalid table name
00903. 00000 -  "invalid table name"

Solution C

CREATE TABLE "SIZE"(
id int, 
name VARCHAR2(100)
)
Table "SIZE" created.

Problem D

--  CONTAINS MORE THAN 30 CHARACTER
CREATE TABLE EMPLOYEE_NAME_WITH_MANAGER_NAME_AND_SENIOR_MANAGER_NAME(
id int, 
name VARCHAR2(100)
)

ORA-00903: invalid table name
00903. 00000 -  "invalid table name"

Solution D

CREATE TABLE EMPLOYEE(
id int, 
name VARCHAR2(100)
)
Table "EMPLOYEE" created.

Solution 2

SQL statements such as select, delete, insert, and update must be written correctly. Oracle could not identify the table name in the query if incorrect syntax was used in the SQL query. As a result, Oracle’s database will throw the invalid table name error.

Problem

delete from table emp;

Error starting at line : 19 in command -
delete from table emp
Error at Command Line : 19 Column : 13
Error report -
SQL Error: ORA-00903: invalid table name
00903. 00000 -  "invalid table name"

Solution

delete from emp;

Solution 3

If a table is created using a special character or reserved keyword enclosed in double quotes, the table shall always be referred to with the enclosed double quotations. If you ignore the double quotes when referring to a table in the select statements, Oracle will be unable to recognize the table name and hence will be unable to locate the table in the database.

The tables with name which are created with special character or reserved keyword must enclose a double quotation while referring in the sql query. The example below illustrates how to refer to a table name using a double quotation mark.

Problem

select * from 1emp;

select * from !emp;

select * from size;

solution

select * from "1emp";

select * from "!emp";

select * from "size";

Ads were blocked — no problem. But keep in mind that developing HeidiSQL,
user support and hosting takes time and money. You may want to
send a donation instead.

1. Select table in the VT;
2. Select Data page, view table content;
3. Select Database page and refresh it by pressing F5 button;
4. Return to Data page and try to refresh data by pressing F5 button;
5. See error massage: SQL Error (1103): Incorrect table name »

Sorry.
Screenshot

Table structure:

CREATE TABLE `rep_triggers` (
`gid` INT(3) UNSIGNED NOT NULL,
`trigger` VARCHAR(50) NOT NULL,
`name` VARCHAR(100) NOT NULL,
`url` VARCHAR(100) NULL DEFAULT NULL,
`mark` INT(1) UNSIGNED NOT NULL DEFAULT '0',
`mark2` INT(1) UNSIGNED NOT NULL DEFAULT '0',
`DTLM` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`trigger`)
)
COLLATE='utf8_general_ci'
ENGINE=MyISAM;

Ah, thanks for the enlightment. I assume you did update your heidisql.exe to a nighly build which then fixed it, as I recall there was a recent fix for exactly this error.

Hi,

I am having the save problem with «SQL Error (1103): Incorrect table name «

here is what’s been triggering the 1103 error code:

SQL query:

CREATE TABLE `admin_pay’ (
` pay_id ‘ bigint(20) NOT NULL auto_increment, `pay_amount’double NOT NULL default ‘0’,
PRIMARY KEY ( `pay_id` ) );

MySQL said: Documentation
#1103 — Incorrect table name ‘admin_pay’ (

I tried adding the

)
COLLATE=’utf8_general_ci’
ENGINE=MyISAM;

to the original SQl.php script like this:

CREATE TABLE `admin_pay’ (
`pay_id’ bigint(20) NOT NULL auto_increment,
`pay_amount’ double NOT NULL default ‘0’,
PRIMARY KEY (`pay_id`)
);


— Dumping data for table `admin_pay`

INSERT INTO `admin_pay` VALUES (1, 0);
)
COLLATE=’utf8_general_ci’
ENGINE=MyISAM;

but it still returned the same 1103 error code.
Can you offer any suggestions that might help solve this error problem?

You have the table name enclosed in two different quote chars: backtick and single quote. Only backticks are allowed quote chars in mysql.

Thank you for bringing that to my attention! Before you mentioned it, I didn’t know a «backtick» and a «single quote» were different. Indeed I did add some «single quotes» to the sql.php page because the «backticks» were so faint and hard to see. I had no clue I was effectively messing up the sql.php page by adding those single quotes to it. Excellent call!

However, I have now replaced all the single quotes I had previously changed, and put with «backticks» in their place. But I’m still get the same «1103» error flag.

So, apparently the » SQL Error (1103): Incorrect table name» error flag I’m getting isn’t being triggered by the single quotes I had added to the page. But rather, it’s being triggered by different problem I haven’t been able to locate yet.

Excellent call, though. Thank you so much for pointing that out! Do you have any more ideas I might try?

when I execute

CREATE TABLE admin_pay (
pay_id bigint(20) NOT NULL auto_increment,
pay_amount double NOT NULL default ‘0’,
PRIMARY KEY (pay_id)
);

it works ok on my system. don´t know why you use all the quotes.

CREATE TABLE admin_pay (
pay_id bigint(20) NOT NULL auto_increment,
pay_amount double NOT NULL default ‘0’,
PRIMARY KEY (pay_id)
)
COLLATE=utf8_general_ci
ENGINE=MyISAM;

works as well.

Wow…I am thoroughly hyped now! I got it to work just as you said! Once I replaced all the single quotes with backticks, it works great! Thanks again!

Maybe you can help me with another issue?

— Table structure for table `affil_heap_sessionid`

CREATE TABLE `affil_heap_sessionid` (
`heap_id` bigint( 20 ) NOT NULL default ‘0’,
`heap_name` varchar( 255 ) NOT NULL default ‘0’,
`heap_regdate` datetime NOT NULL default ‘0000-00-00.00.00’,
`heap_approved` bigint( 20 ) NOT NULL default ‘0’,
`heap_pending` bigint( 20 ) NOT NULL default ‘0’,
`heap_paid` bigint( 20 ) NOT NULL default ‘0’,
PRIMARY KEY ( `heap_id` )

I’m getting a syntax error 1064 that states:
Message: %s near ‘%s’ at line %d

The heap_regdate column has an invalid default value:
Wrong: 0000-00-00.00.00
Right: 0000-00-00 00:00:00

Got it. Thank you again. Everything seems to be working great now. Couldn’t have done it without your help. Many thanks!

CREATE TABLE `project`.`registration ` (

`name ` VARCHAR( 200 ) NOT NULL ,
`email` VARCHAR( 200 ) NOT NULL ,
`password` VARCHAR( 100 ) NOT NULL ,
`mobile` VARCHAR( 100 ) NOT NULL ,
`dob` VARCHAR( 100 ) NOT NULL ,
`pre_add` VARCHAR( 200 ) NOT NULL ,
`profession` VARCHAR( 200 ) NOT NULL ,
`org` VARCHAR( 200 ) NOT NULL ,
`designation` VARCHAR( 200 ) NOT NULL ,
`passyr` DATE NOT NULL ,
`passgrp` VARCHAR( 100 ) NOT NULL ,
`gender` VARCHAR( 50 ) NOT NULL ,
`m_status` VARCHAR( 50 ) NOT NULL ,
`bloodgrp` VARCHAR( 50 ) NOT NULL ,
`sl` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`par_add` VARCHAR( 200 ) NOT NULL ,
PRIMARY KEY ( `sl` )
) ENGINE = INNODB;

MySQL said: Documentation

#1103 — Incorrect table name ‘registration ‘

Same problem in previous post, I guess.

CREATE TABLE `tezaver_metaphone ` (
    `term` VARCHAR(400) NOT NULL,
    `metaphone` TEXT NOT NULL
)
COLLATE='utf8_slovenian_ci'
ENGINE=MyISAM
;

/* SQL Error (1103): Incorrect table name 'tezaver_metaphone ' */

Note space after ‘tezaver_metaphone ‘, that could be auto removed by Heidi, I guess.

I run into this error message using the following workflow. Let me know if this should be a new ticket instead.

SQL Error (1103): Incorrect table name »

Version: 9.4.0.5174 / MariaDB server
Steps to reproduce:

  1. Open any tables data tab
  2. Go back to the tree or database views
  3. Drop that table
  4. Go back to the data tab
  5. Refresh
  6. See this error
  7. Run a script or use a different client to re-create the table
  8. Refresh again

The heidi client is requesting «SELECT * FROM db.« LIMIT 1000;»

Proposed ideas:

  • Dropping a table should keep the old table name around, and properly tell you dropped_table doesn’t exist
  • Have Data tab realize there is no table, so refresh isn’t an option

Please login to leave a reply, or register at first.

This page uses cookies to show you non-personalized advertising and server usage statistic diagrams.

  • Laravel Version: #.#.# Laravel Framework 5.6.38
  • PHP Version: PHP Version 7.1.9
  • Laravel-admin: #.#.# latest

Description:

D:xampphtdocslara-admin>php artisan admin:install

IlluminateDatabaseQueryException : SQLSTATE[42000]: Syntax error or access
violation: 1103 Incorrect table name » (SQL: create table « (id int unsigne
d not null auto_increment primary key, `username` varchar(190) not null, `passwo
rd` varchar(60) not null, `name` varchar(255) not null, `avatar` varchar(255) nu
ll, `remember_token` varchar(100) null, `created_at` timestamp null, `updated_at
` timestamp null) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’)

at D:xampphtdocslara-adminvendorlaravelframeworksrcIlluminateDatabase
Connection.php:664
660| // If an exception occurs when attempting to run a query, we’ll
format the error
661| // message to include the bindings with SQL, which will make th
is exception a
662| // lot more helpful to the developer instead of just the databa
se’s errors.
663| catch (Exception $e) {

664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|

Steps To Reproduce:

php artisan admin:install

Code_Of_God

0 / 0 / 0

Регистрация: 02.06.2015

Сообщений: 52

1

10.11.2016, 15:47. Показов 3367. Ответов 6

Метки нет (Все метки)


Помогите исправить!

SQL
1
2
3
4
5
6
7
8
9
CREATE TABLE  IF NOT EXISTS AIS_DomRu.Сlient(
    №Contract INT NOT NULL AUTO_INCREMENT,
    idRequest INT,
    PassportDate VARCHAR(150),
    №Account INT,
    STATUS VARCHAR(30),
    PRIMARY KEY (№Contract),
    FOREIGN KEY (idRequest) REFERENCES AIS_DomRu.Request(idRequest)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Модератор

4186 / 3026 / 576

Регистрация: 21.01.2011

Сообщений: 13,096

10.11.2016, 16:25

2

Цитата
Сообщение от Code_Of_God
Посмотреть сообщение

Помогите исправить

Ты уверен, что символ № допустим в имени объекта?



0



0 / 0 / 0

Регистрация: 02.06.2015

Сообщений: 52

10.11.2016, 19:07

 [ТС]

3

Цитата
Сообщение от Grossmeister
Посмотреть сообщение

символ №

да конечно, жалуется же на имя таблицы а не на поля



0



24 / 24 / 7

Регистрация: 27.02.2013

Сообщений: 113

11.11.2016, 06:05

4

Для имен баз данных и таблиц нельзя использовать точку и
разделители



0



0 / 0 / 0

Регистрация: 02.06.2015

Сообщений: 52

11.11.2016, 22:40

 [ТС]

5

Цитата
Сообщение от ita2907
Посмотреть сообщение

Для имен баз данных и таблиц нельзя использовать точку и
разделители

в том то и дело даже если ее убрать то все равно оно не работает, и жалуется на имя!



0



24 / 24 / 7

Регистрация: 27.02.2013

Сообщений: 113

14.11.2016, 07:10

6

AIS_DomRu. — это не имя таблицы, это имя базы данных, в которую входит т. Client.
А Вы уверены, что у Вас есть такая база?



0



Dilshod Komilov

40 / 41 / 13

Регистрация: 10.08.2016

Сообщений: 310

14.11.2016, 07:43

7

Code_Of_God, , Попробуй написать это:

MySQL
1
 FOREIGN KEY (idRequest) REFERENCES AIS_DomRu.Request(idRequest)

после ) тоесть перед ENGINE…..



0



0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Ошибка incorrect syntax near the keyword from
  • Ошибка ico посудомоечная машина электролюкс