title: mysqldump creates Table instead of a View
body: <p>I have a script on server that should backup all databases, but it saves all views as tables. I suppose that I have a keys for <code>mysqldump</code> wrong. Can anyone help me to get them right?</p>
  
  <h2>script:</h2>
  
  <pre><code>mysql -uroot -pxxx -e "SHOW DATABASES;" &gt; dblist.txt
  exec &lt; dblist.txt
  read dbname1
  while read dbname
      do
         mysqldump -uroot -pxxx -r ${dbname}.sql --routines --add-drop-database --default-character-set=cp1251 --create-options --complete-insert $dbname || echo -e "${dbname} backup failed!"
      done
  </code></pre>
  
  <h2>Output:</h2>
  
  <pre><code>--
  -- Temporary table structure for view `Events`
  --
  
  DROP TABLE IF EXISTS `Events`;
  /*!50001 DROP VIEW IF EXISTS `Events`*/;
  SET @saved_cs_client     = @@character_set_client;
  SET character_set_client = utf8;
  /*!50001 CREATE TABLE `Events` (
    `id` tinyint NOT NULL,
    `name` tinyint NOT NULL,
    `subname` tinyint NOT NULL,
    `description` tinyint NOT NULL,
    ...
    `subname_e` tinyint NOT NULL
  ) ENGINE=MyISAM */;
  SET character_set_client = @saved_cs_client;
  </code></pre>
  
  <h2>What actually in DB:</h2>
  
  <pre><code>MySQL [(none)]&gt; show create table `Events`\G;
  *************************** 1. row ***************************
              View: Events
       Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db`.`Events` AS select `e`.`id` AS `id`,`e`.`name` AS `name`,`e`.`subname` AS `subname`,`e`.`description` AS `description`, ... `e`.`subname_e` AS `subname_e` from (`db1`.`Events` `e` left join `db2`.`EventsSitesLogo` `s` on((`e`.`id` = `s`.`eventid`)))
  character_set_client: utf8
  collation_connection: utf8_unicode_ci
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>mysql-server version: <strong>5.1.73</strong></p>
  
  <p><strong>EDIT1</strong>: I stumbled upon information that the table I see in dump-file is a temporary table that is meant to ensure that views that are made on the base of other view(s) are made correctly, while actual algorithms for views' creation are always at the end of backup. However, my file ends with these lines:</p>
  
  <pre><code>/*end of normal tables dump*/    
  
  --
  -- Dumping routines for database 'db'
  --
  </code></pre>
  
  <p>Nothing more. No views. Please help.</p>