Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View and table in same name is it possible

Is it possible to create a mysql view and table in same name

for example i have a table hs_hr_employee i want create a view as a same name

create VIEW hs_hr_employee AS SELECT * from hs_hr_employee;

I m getting following error

#1050 - Table 'hs_hr_employee' already exists

Any help Thankful

Regards

like image 603
Roshan Wijesena Avatar asked Jul 21 '11 11:07

Roshan Wijesena


People also ask

Can a view and table have same name SQL?

A schema cannot contain a table and view with the same name. A CREATE VIEW statement produces an error if a table with the same name already exists in the schema.

Can we create a view and table with same name in SQL Server?

Within a database, base tables and views share the same namespace, so a base table and a view cannot have the same name.

Can we use same name for a table and view in hive?

The name of a view must be unique, and it cannot be the same as any table or database or view's name.

Can we create table and view with same name in Oracle?

Because tables and views are in the same namespace, a table and a view in the same schema cannot have the same name. However, tables and indexes are in different namespaces. Therefore, a table and an index in the same schema can have the same name.


1 Answers

you can't , give to view different name like

hs_hr_employee_view

from manual

Within a database, base tables and views share the same namespace, so a base table and a view cannot have the same name.

like image 92
Haim Evgi Avatar answered Sep 19 '22 17:09

Haim Evgi