Documentation Home
MySQL Shell for VS Code


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

Pre-General Availability: 2024-03-18

8.3 DB Notebook: Create and Drop a View

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

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

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"
  }
]