PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

Select Database

← All stacks

Theory

9/439

Select Database

USE college; selects which database later statements talk to. It does not print the table. Think: open this cupboard, then look at registers inside.

In Workbench the schema you highlight is the same idea. In an app, the connection already names the database, so you often skip USE.

Check — SELECT DATABASE(); shows the one in use. NULL means you did not select any.

Trap — running SELECT * FROM students without USE, and MySQL says ‘No database selected’.

On the example next to this theory — Select Database — sELECT projects columns; WHERE filters; ORDER BY sorts.

Diagram
  FROM students
        │
        ▼
  WHERE city = 'Pune'
        │
        ▼
  SELECT name, marks
Exam tip

USE college; then SELECT DATABASE();

Select Database — sample query

CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT, dept TEXT, salary INTEGER);
INSERT INTO employees VALUES
  (1, 'Asha', 'Eng', 70000),
  (2, 'Ravi', 'Eng', 65000),
  (3, 'Neha', 'HR', 50000);
SELECT name, salary FROM employees WHERE dept = 'Eng' ORDER BY salary DESC;

Select Database — sELECT projects columns; WHERE filters; ORDER BY sorts.

Short notes

  • DefUSE dbname; picks the database for the session.
  • RuleSELECT DATABASE(); to check.
  • TrapQuery without USE → no database selected.

Questions

1

How do you select a database?

9 / 439

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.