Documentation Home
MySQL Shell for VS Code


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

Pre-General Availability: 2024-03-18

9.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' ",  
(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%' ",  
(IResultSetData) => {
    print(IResultSetData);
  }
);

The output is:

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