创建数据库表(MySQL)
我正在尝试创建一个数据库脚本,其中包含以下步骤的SQL代码,以及 使用MySQL Workbench执行每个步骤,创建并填充一个新表 在fooddb中称为recipe 该配方表应具有以下对象变量的列:id using auto 增量、标题、指令(仅一个字符串)、numServings和totalTime in 分钟 编辑3-11/4/2014-15:32。。。我可能已经弄明白了,但是我不太确定:创建数据库表(MySQL),mysql,sql,database,create-table,Mysql,Sql,Database,Create Table,我正在尝试创建一个数据库脚本,其中包含以下步骤的SQL代码,以及 使用MySQL Workbench执行每个步骤,创建并填充一个新表 在fooddb中称为recipe 该配方表应具有以下对象变量的列:id using auto 增量、标题、指令(仅一个字符串)、numServings和totalTime in 分钟 编辑3-11/4/2014-15:32。。。我可能已经弄明白了,但是我不太确定: create table recipe ( RecipeID int not null auto_
create table recipe (
RecipeID int not null auto_increment,
'RecipeName' varchar(300),
'RecipeType' varchar(100),
"Instructions" text,
NumOfServings int not null,
TotalTimeInMinutes int not null,
primary key(RecipeID));
insert into recipe values (0, 'RecipeName', 'RecipeType', "Instructions", 0, 0);
select * from recipe;
这有什么问题吗?您应该看看mysql手册,了解如何创建数据库/表: 还有一些关于如何创建表的示例 编辑: 您可以执行以下任一操作:
INSERT INTO recipe (name, category) VALUES ('Recipename', 'Categoryname');
因为您只指定要添加数据的列
或
因为如果不指定列,就必须给出所有列的所有数据。在MySQL数据库中测试我编辑的MySQL代码后,我可以确认测试时键入的内容是正确的
这主要是因为我在经历了所有的错误之后,对它进行了阅读和重新打字……/P>如果你在S/W开发环境中需要它,你可以考虑液基而不是脚本。我已经相应地采纳了你的建议,并查找了其他有关如何更有效地解决这个问题的来源。谢谢你的帮助。
INSERT INTO recipe VALUES (0, 'Recipename', 'CategoryName');