错误代码:1046在MySQL中创建数据库时没有选择数据库

时间:2018-04-08 15:47:42

标签: mysql

我收到一条错误消息“错误代码:1046没有数据库选择”使用MySQL 下面是我写的脚本,有关为什么我收到错误消息的任何建议?

DROP DATABASE IF EXISTS Bookstore;

Create Database Bookstore;


Use Bookstore;


Create Table Subject
(SubjectCode    nvarchar(3) Not Null primary key,
Subject nvarchar(15)    Null);

Create Table Book
(ISBN   nvarchar(13)    Not Null primary key,
Title   nvarchar(50)    Null,
Author  nvarchar(30)    Null,
Publisher   nvarchar(30)    Null,
Subject_Code    nvarchar(3) Null References Subject (Subject_Code),
Shelf_Location  nvarchar(7) Null,
Fiction bit Null);


Use Bookstore;
Insert Into Subject
Values
    ('ART', 'Art'),
    ('BSN', 'Business'),
    ('BSS', 'Best Seller'),
    ('EDC', 'Education'),
    ('FNT', 'Fantasy'),
    ('HMR', 'Humor'),
    ('MST', 'Myster'),
    ('PHL', 'Philosophy'),
    ('RLG', 'Religion'),
    ('RMN', 'Romance'),
    ('SCF', 'Science Fiction'),
    ('SLH', 'Self Help');

Use Bookstore;    
Insert Into Book
Values
    ('0-111-11111-1', '89 Years in a Sand Trapxx', 'Beck, Fred', 'Hill and Wang', 'HMR', 'RC-1111', '0'),
    ('0-15-500139-6', 'Business Programming in C', 'Milsspaugh, A.C.', 'The Dryden Press', 'BSN', 'RC-1111', '0'),
    ('0-394-75843-9', 'Cultural Literacy', 'Hirsch, E.D. Jr.', 'Vintage', 'Bss', 'RC-1115', '0'),
    ('0-440-22284-2', 'Five Days in Paris', 'Steel, Daniels', 'Dell Publishing', 'RMN', 'RC-1114', '0'),
    ('0-446-51251-6', 'Megatrends', 'Naisbitt, John', 'Warner Books', 'PHL', 'RC-1114', '0'),
    ('0-446-51652-X', 'Bridges of Madison County', 'Waller, Robert James', 'Warner Books', 'BSS', 'RC-1114', '1'),
    ('0-446-60274-4', 'The Rules', 'Fein/Schneider', 'Warner Books', 'SLH', 'RC-1111', '0'),
    ('0-451-16095-9', 'The Stand', 'King, Stephen', 'Signet', 'MST', 'RC-1113', '0'),
    ('0-452-26011-6', 'Song of Solomon', 'Morrision, Toni', 'Plume/Penguin', 'BSS', 'Rc-1114', '1'),
    ('0-517-59905-8', 'How to Talk to Anyone, Anytime, Anywhere', 'King, Larry', 'Crown', 'SLH', 'RC-1113', '0'),
    ('0-534-26076-4', 'A Quick Guide to the Internet', 'Filus, Steve', 'Intergrated Media Group', 'BSN', 'RC-1111', '0'),
    ('0-553-24484-X', 'Prospering Woman', 'Ross, Ruth', 'Bantam Brooks', 'SLH', 'RC-1111', '0'),
    ('0-670-85332-1', 'How to be Hap-Hap-Happy Like Me', 'Markoe, Merrill', 'Viking', 'HMR', 'RC-1113', '1'),
    ('0-671-67158-8', 'Time Wars', 'Rifkin, Jeremy', 'Simon and Schuster', 'PHL', 'RC-1115', '0'),
    ('0-697-12897-0', 'Quick Basic and QBasic Using Modular Structure', 'Filus, Steve', 'B & E Tech', 'BSN', 'RC-1112', '0'),
    ('0-697-21361-7', 'Desktop Publishing Using PageMaker 5.0', 'Filus, Steve', 'B & E Tech', 'BSN', 'RC-1111', '0'),
    ('0-8007-1213-7', 'Secrets of Closing the Sale', 'Ziglar, Zig', 'Revel', 'BSN', 'RC-1112', '0'),
    ('0-8041-0753-X', 'The Kitchen God''s Wife', 'Tan, Amy', 'Ivy Books', 'BSS', 'RC-1113', '1'),
    ('0-8109-3158-3', 'Thomas Cole', 'Powell, Earl A.', 'Abrams', 'ART', 'RC-1112', '0'),
    ('0-8109-8052-5', 'The Art of Walt Disney', 'Finch, Christopher', 'Albradale', 'Art', 'RC-1112', '0'),
    ('0-8487-0504', 'Erica Wilson''s Quilts of America', 'Wilson, Erica', 'Oxmoor House', 'ART', 'RC-1112', '0'),
    ('0-87826-2', 'Know Your Lhaso Apso', 'Schneider, Earl', 'The Pet Library LTD', 'SLH', 'RC-1112', '0'),
    ('0-89997=087-7', 'Afoot and Afield in Orange County', 'Schad, Jerry', 'Wilderness Press', 'SLH', 'RC-1112', '0'),
    ('0-915391-40-6', 'Designing User Interfaces', 'Powell, James E.', 'Micontrend', 'BSN', 'RC-1114', '0'),
    ('0-917849-25-6', 'I am enough', 'Stortz, Margaret', 'Science of Mind', 'PHL', 'RC-115', '0'),
    ('0-934136-27-0', 'Wine Makers Guide', 'Nury/Fugelsang', 'Western Tanager', 'MST', 'RC-1112', '0'),
    ('0-9616878-6-X', 'Classics, US Aircraft of World War II', 'Meyer, Mark', 'Howell Press', 'ART', 'RC-1112', '0'),
    ('1-55615-484-4', 'Code Complete', 'Mc Connell, Steve', 'Microsoft Press', 'BSN', 'RC-1115', '0'),
    ('1-82423-2218-3', 'The Way', 'Chaney, Elana', 'Tyndale', 'RLG', 'RC-1111', '0');

1 个答案:

答案 0 :(得分:0)

确保使用以下命令创建数据库:

Create Database dbname