mysql> create table tb01 (id int,name varchar(10)); ERROR 1146 (42S02): Table 'da01.tb01' doesn't exist
时间: 2024-05-14 17:15:15 浏览: 101
This error occurs when you try to create a table named tb01 in a database named da01, but the database does not exist. You need to create the database first before creating the table.
To create a database, use the following command:
```
CREATE DATABASE da01;
```
Then, you can create the table using the following command:
```
CREATE TABLE tb01 (id INT, name VARCHAR(10));
```
This will create a table named tb01 with two columns, id and name.
相关问题
mysql> create table tb01; ERROR 1146 (42S02): Table 'da01.tb01' doesn't exist
This error occurs because you are trying to create a table without specifying the columns in it. To create a table, you need to specify the table name and the columns with their data types.
Here's an example of how to create a table named tb01 with two columns, id (integer) and name (varchar):
```
mysql> CREATE TABLE tb01 (
-> id INT,
-> name VARCHAR(50)
-> );
```
Once you've created the table, you can start adding data to it using the INSERT INTO statement.
用C++,编写一个简单程序,设计一个建筑物类 Building,由它派生出教学楼类 TeachBuilding 和宿舍楼类 DormBuilding, 前者包括教学楼编号、层数、教室数、总面积等基本信息,后者包括宿舍楼编号、层数、宿舍数、总面积和容纳学生总人数等基本信息。
好的,下面是一个简单的C++程序示例,展示了如何设计这个层次结构:
```cpp
#include <iostream>
#include <string>
// 定义一个基础的建筑物类 Building
class Building {
public:
Building(const std::string& id, int floors, double area) : building_id(id), floors(floors), total_area(area) {}
virtual ~Building() {}
// 简单的属性获取
std::string get_building_id() const { return building_id; }
int get_floors() const { return floors; }
double get_total_area() const { return total_area; }
protected:
std::string building_id;
int floors;
double total_area;
};
// 派生出教学楼类 TeachBuilding,并添加教室信息
class TeachBuilding : public Building {
private:
int classrooms;
public:
TeachBuilding(const std::string& id, int floors, int classrooms, double area)
: Building(id, floors, area), classrooms(classrooms) {}
// 教室数的获取
int get_classrooms() const { return classrooms; }
// 打印特定信息
void print_info() const override {
std::cout << "Teaching Building ID: " << building_id << ", Floors: " << floors << ", Classrooms: " << classrooms << ", Total Area: " << total_area << std::endl;
}
};
// 派生出宿舍楼类 DormBuilding,添加宿舍和容纳人数信息
class DormBuilding : public Building {
private:
int dorms;
int capacity;
public:
DormBuilding(const std::string& id, int floors, int dorms, int capacity, double area)
: Building(id, floors, area), dorms(dorms), capacity(capacity) {}
// 宿舍数和容纳人数的获取
int get_dorms() const { return dorms; }
int get_capacity() const { return capacity; }
// 打印特定信息
void print_info() const override {
std::cout << "Dormitory Building ID: " << building_id << ", Floors: " << floors << ", Dormitories: " << dorms << ", Capacity: " << capacity << ", Total Area: " << total_area << std::endl;
}
};
int main() {
TeachBuilding teach("TB01", 5, 20, 10000);
teach.print_info();
DormBuilding dorm("DB01", 4, 15, 900, 8000);
dorm.print_info();
return 0;
}
```
在这个例子中,`Building`是基类,`TeachBuilding`和`DormBuilding`是它的派生类。每个派生类都覆盖了`print_info()`函数,以显示它们特有的信息。
阅读全文