Search code examples
mysqlviewrdbms

What happens to sql views, if database is moved to another server


I have created a view in my current database. But now I'm moving the database to another server. Normally I'm taking the dump, but not sure about views.

Will they come when I import the dump and work as per the view? Or I need to create view again?


Solution

  • The dump you create with mysqldump will contain the CREATE VIEW statements.

    The MySQL documentation says:

    mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW for dumped views, TRIGGER for dumped triggers, and LOCK TABLES if the --single-transaction option is not used. Certain options might require other privileges as noted in the option descriptions.