mysql SQL错误代码:1049.未知数据库'dbo'

ubof19bj  于 2022-12-03  发布在  Mysql
关注(0)|答案(2)|浏览(435)

我试图创建一个数据库使用mysql工作台,我不断得到这个错误,我的代码看起来很好。不知道我如何可以解决这个问题。这是我得到的错误:错误代码:1049.未知的数据库'dbo'。我尝试了很多方法,但只有创建和使用数据库的前两行有效。[随附屏幕截图]

use employeedb;

create table dbo.Department(
DeprartmentId int AUTO_INCREMENT,
DepartmentName nvarchar(500),
PRIMARY KEY(DepartmentId)
);

insert into dbo.Department(DepartmentName) values ('IT');
insert into dbo.Department(DepartmentName) values ('Support');

create table dbo.Employee(
EmployeeId int AUTO_INCREMENT,
EmployeeName nvarchar(500),
Department nvarchar(500),
DateOfJoining datetime,
PhotoFileName nvarchar(500),
PRIMARY KEY(EmployeeId)
);

insert into dbo.Employee(EmployeeName,Department,DateOfJoining,PhotoFileName) 
values                  ('John','IT','2022-11-27','anonymous.png');

select * from dbo.Employee;
tp5buhyn

tp5buhyn1#

您似乎使用了SQL Server语法,但这在MySQL上不起作用。以下是针对MySQL更新的脚本:

USE employeedb;

CREATE TABLE Department (
    DeprartmentId int AUTO_INCREMENT,
    DepartmentName varchar(500),
    PRIMARY KEY(DepartmentId)
);

INSERT INTO Department(DepartmentName) VALUES ('IT');
INSERT INTO Department(DepartmentName) VALUES ('Support');

CREATE TABLE Employee (
    EmployeeId int AUTO_INCREMENT,
    EmployeeName varchar(500),
    Department varchar(500),
    DateOfJoining datetime,
    PhotoFileName varchar(500),
    PRIMARY KEY(EmployeeId)
);

INSERT INTO Employee (EmployeeName, Department, DateOfJoining, PhotoFileName) 
VALUES ('John', 'IT', '2022-11-27', 'anonymous.png');

SELECT * FROM Employee;
vdgimpew

vdgimpew2#

似乎您正在从MSSQL更改为MySQL,因为MySQl不需要“dbo”,只需:
使用雇员b;
创建表部门(部门ID int AUTO_INCREMENT,部门名称nvarchar(500),主键(部门ID));....

相关问题