Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (20.3k points)

Error SQL query:

--

-- Database: `work`

--

-- --------------------------------------------------------

--

-- Table structure for table `administrators`

--

CREATE TABLE IF NOT EXISTS `administrators` (

`user_id` varchar( 30 ) NOT NULL ,

`password` varchar( 30 ) NOT NULL ) ENGINE = InnoDB DEFAULT CHARSET = latin1;

MySQL said:

#1046 - No database selected

need some help here.

1 Answer

0 votes
by (40.4k points)
edited by

Before creating the table, you need to specify which database you are using in MYSQL. 

USE db_name;

Are you interested in learning SQL from the basics! Refer to this video on SQL provided by Intellipaat:

If in case the database does not exist, then you should create it as:

CREATE DATABASE db_name;

Which needs to be followed by:

USE db_name;

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.2k users

Browse Categories

...