Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

alter table error ERROR 1347 (HY000): 'table-name' is not BASE TABLE in mysql

Recently I attempted to add a column to one of the tables of my database which has 316 table but after the following command:

mysql> ALTER TABLE view_Server ADD rsh_protocol VARCHAR(60);

I get the following error :

ERROR 1347 (HY000): 'itop.view_Server' is not BASE TABLE

all my searches was unsuccessful like using '``'. So the question is that what's the reason of this error? and how can I git ride of that?

like image 498
Mazdak Avatar asked Sep 19 '15 07:09

Mazdak


1 Answers

From your "table" name, are you trying to add a column to a view?

Run through each of these:

CREATE TABLE x (id INT, name VARCHAR(255));

INSERT INTO x VALUES (1, 'One');
INSERT INTO x VALUES (2, 'Two');

-- A view with no change of column names
CREATE VIEW y AS SELECT id FROM x;

SELECT * FROM y;

-- Change the view, again using the base table column names
ALTER VIEW y AS SELECT name FROM x;

SELECT * FROM y;

-- Change the view, switching column name from `name` to `theName`
ALTER VIEW y (theName) AS SELECT name FROM x;

SELECT * FROM y;

-- Change the view, switching column name to `anotherName` by aliasing in the SELECT
ALTER VIEW y AS SELECT name anotherName FROM x;

SELECT * FROM y;
like image 162
Adrian Lynch Avatar answered Sep 25 '22 16:09

Adrian Lynch