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

SQL · Theory

TRUNCATE()()

← All stacks

Theory

184/439

TRUNCATE()()

TRUNCATE() is a MySQL math function: TRUNCATE(x, d) cuts decimals without rounding — not TRUNCATE TABLE. Use it in SELECT, e.g. SELECT TRUNCATE(marks) FROM students;

These functions do not change stored marks unless you UPDATE. NULL in, NULL out for most of them.

Trap — mixing TRUNCATE with TRUNCATE TABLE (different word). Trap: maths on VARCHAR without CAST.

In a viva, one numeric example beats listing twenty functions.

On the example next to this theory: TRUNCATE()() — dELETE removes matching rows. TRUNCATE clears a whole table faster (MySQL).

Exam tip

Explain TRUNCATE with one number. TRUNCATE(x, d) cuts decimals without rounding — not TRUNCATE TABLE.

TRUNCATE()() — sample query

CREATE TABLE tags (id INTEGER PRIMARY KEY, label TEXT);
INSERT INTO tags VALUES (1, 'old'), (2, 'keep');
DELETE FROM tags WHERE label = 'old';
SELECT * FROM tags;

TRUNCATE()() — dELETE removes matching rows. TRUNCATE clears a whole table faster (MySQL).

Short notes

  • DefTRUNCATE() — TRUNCATE(x, d) cuts decimals without rounding — not TRUNCATE TABLE.
  • RuleSELECT the function; UPDATE only if you mean to store it.
  • TrapNULL in → NULL out. Don’t confuse with table TRUNCATE.

Questions

1

What is TRUNCATE?

184 / 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.