我已经上传了一个使用SQL数据库的作业。
我们通过localhost / phpadmin,我正在使用xampp。他告诉我我的sql文件加载失败,我需要重新上传它。他还说:“脚本的第一行应该是删除数据库(如果存在的话)。这将使您能够测试脚本和代码,以确保所有内容都能正常工作。”当我对其进行测试之前,它们都可以很好地工作,所以我有些困惑。
我想确保自己的代码中有正确的主意,该做什么。我删除数据库所在的行,这是执行他所要求的正确方法吗?还是有更好的方法或更多方法来满足需要?
USE master
IF EXISTS(select * from sys.databases where name='richard_ricardo_assignment_db')
DROP DATABASE richard_ricardo_assignment_db
CREATE DATABASE richard_ricardo_assignment_db;
CREATE USER 'richardweb'@'localhost' IDENTIFIED BY 'richardchocolate';
/*GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'richardweb'@'localhost' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;*/
GRANT SELECT, INSERT, UPDATE, DELETE ON `richard\_ricardo\_assignment\_db`.* TO 'richardweb'@'localhost';
/*GRANT SELECT, INSERT, UPDATE, DELETE, FILE ON richard_ricardo_assignment_db.* TO 'richardweb'@'localhost';
FLUSH PRIVILEGES;*/
CREATE table Student (
studentID int,
name varchar(255),
email varchar(255),
PRIMARY KEY (studentID)
);
INSERT INTO Student (studentID, name, email)
VALUES (1, "Po Black", "poblack@gmail.com"),(2, "Shifu Hoffman", "shifuhoffman@gmail.com"),(3, "Tigress Jolie", "tigressjolie@gmail.com"),(4, "Jennifer Yuh", "jenniferyuh@gmail.com"),
(5, "Ox Storming", "oxstorming@gmail.com"),(6, "Monkey Chan", "monkeychan@gmail.com"),(7, "Viper Liu", "viperliu@gmail.com"),(8, "Mantis Rogen", "mantisrogen@gmail.com"),
(9, "Crane Cross", "cranecross@gmail.com"),(10, "Oogway Kim", "oogwaykim@gmail.com"),(11, "Ping Hong", "pinghong@gmail.com");