Documentation Home
MySQL Shell for VS Code


MySQL Shell for VS Code  /  JavaScript  /  DB Notebook: Create and Drop a View

8.3 DB Notebook: Create and Drop a View

DB Notebook: Create a view and show a table using LIKE

Press CTRL+C to copy
runSql("CREATE VIEW AlbertaAddresses AS SELECT * FROM sakila.address WHERE district = 'Alberta'"); //check TABLES for successful CREATE VIEW runSql("SHOW TABLES LIKE 'AlbertaAddresses' ", function (ResultSetData) { print(ResultSetData); });

The output is:

[
  {
      "Tables_in_sakila (AlbertaAddresses)": "albertaaddresses"

  }
]

DB Notebook: Drop a view and show tables using LIKE

Press CTRL+C to copy
runSql("DROP VIEW IF EXISTS albertaaddresses"); //check TABLES for successful DROP VIEW runSql("SHOW TABLES LIKE 'A%' ", function (IResultSetData) { print(IResultSetData); });

The output is:

[
  {
      "Tables_in_sakila (A%)": "actor"
  },
  {
      "Tables_in_sakila (A%)": "actor_info"
  },
  {  
      "Tables_in_sakila (A%)": "address"
  }
]