156 lines
3.4 KiB
Plaintext
156 lines
3.4 KiB
Plaintext
---
|
|
title: MindsDB Projects
|
|
sidebarTitle: MindsDB Projects
|
|
---
|
|
|
|
MindsDB enables you to group all objects within [projects](/sql/project).
|
|
|
|
Projects store [all MindsDB schema objects](/sql/table-structure#the-information-schema-database) except for handlers, connected data sources, and configured AI/ML engines. That is, projects can store models, views, jobs, triggers, agents, skills, knowledge bases, and chatbots.
|
|
|
|
MindsDB provides the default `mindsdb` project where all objects created without defining a project are stored.
|
|
|
|
## Working with MindsDB Projects
|
|
|
|
### Create a Project
|
|
|
|
Use the below command to create a project.
|
|
|
|
```sql
|
|
CREATE PROJECT project_name;
|
|
```
|
|
|
|
<Tip>
|
|
Use lower-case letters for a project name.
|
|
</Tip>
|
|
|
|
### List All Projects
|
|
|
|
Use the below command to list all projects.
|
|
|
|
```sql
|
|
SHOW [FULL] DATABASES
|
|
WHERE type = 'project';
|
|
```
|
|
|
|
### Create an Object within a Project
|
|
|
|
Use the below command template to create an object within a project.
|
|
|
|
```sql
|
|
CREATE <OBJECT> project_name.object_name
|
|
...;
|
|
```
|
|
|
|
### Drop a Project
|
|
|
|
Use the below command to remove a project.
|
|
|
|
```sql
|
|
DROP PROJECT project_name;
|
|
```
|
|
|
|
<Note>
|
|
Please note that if your project stores at least one object, it cannot be removed. In this case, you should first drop all the objects belonging to this project, and then, you can remove the project.
|
|
Please see the [Example](#example) section for details.
|
|
</Note>
|
|
|
|
## Example
|
|
|
|
Let's create a project.
|
|
|
|
```sql
|
|
CREATE PROJECT my_project;
|
|
```
|
|
|
|
To verify that the project was created successfully, let's run the command below to select all databases, including connected data sources and projects.
|
|
|
|
```sql
|
|
SHOW FULL DATABASES;
|
|
```
|
|
|
|
On execution, we get:
|
|
|
|
```sql
|
|
+------------------+-------+------+
|
|
|Database |TYPE |ENGINE|
|
|
+------------------+-------+------+
|
|
|information_schema|system |[NULL]|
|
|
|mindsdb |project|[NULL]|
|
|
|my_project |project|[NULL]|
|
|
|files |data |files |
|
|
+------------------+-------+------+
|
|
```
|
|
|
|
<Note>
|
|
Please note that `information_schema` is the system database, `mindsdb` is the default project, and `files` is the database to store all uploaded files. For more information, please visit our docs on [MindsDB default structure](/sql/table-structure/).
|
|
</Note>
|
|
|
|
Now we create a model within the project.
|
|
|
|
```sql
|
|
CREATE MODEL my_project.my_model
|
|
FROM example_db
|
|
(SELECT * FROM demo_data.home_rentals)
|
|
PREDICT rental_price;
|
|
```
|
|
|
|
Also, let's create a view.
|
|
|
|
```sql
|
|
CREATE VIEW my_project.my_view (
|
|
SELECT *
|
|
FROM example_db.demo_data.home_rentals
|
|
);
|
|
```
|
|
|
|
Here is what we have in the `my_project` project.
|
|
|
|
```sql
|
|
SHOW TABLES FROM my_project;
|
|
```
|
|
|
|
On execution, we get:
|
|
|
|
```sql
|
|
+--------------------+
|
|
|Tables_in_my_project|
|
|
+--------------------+
|
|
|my_model |
|
|
|my_view |
|
|
+--------------------+
|
|
```
|
|
|
|
Let's try to delete our project.
|
|
|
|
```sql
|
|
DROP PROJECT my_project;
|
|
```
|
|
|
|
On execution, we get:
|
|
|
|
```sql
|
|
Project 'my_project' can not be deleted, because it contains tables: my_model, my_view
|
|
```
|
|
|
|
Users should remove all project content before dropping a project.
|
|
|
|
```sql
|
|
DROP MODEL my_project.my_model;
|
|
DROP VIEW my_project.my_view;
|
|
```
|
|
|
|
Now we can proceed to drop a project.
|
|
|
|
```sql
|
|
DROP PROJECT my_project;
|
|
```
|
|
|
|
<Info>
|
|
**Next Steps**
|
|
|
|
Below are the links to help you explore further.
|
|
|
|
* Find out how to [create and use projects](/sql/create/project).
|
|
* Learn more about [MindsDB Schema](/sql/table-structure).
|
|
</Info>
|