MariaDB Substring Function Docs
You extract partial text in a query by following the mariadb substring function docs. You pass the target string, a starting position, and an optional length value. Engineering teams often use this built-in function to slice text columns during fixing. They also use it to hide full card numbers or phone numbers in reports. Still, database roles that grant table read access still expose the underlying raw columns. Anyone with broad read rights can skip the function and query the full text. How
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You extract partial text in a query by following the mariadb substring function docs. You pass the target string, a starting position, and an optional length value. Engineering teams often use this built-in function to slice text columns during fixing. They also use it to hide full card numbers or phone numbers in reports. Still, database roles that grant table read access still expose the underlying raw columns. Anyone with broad read rights can skip the function and query the full text.
How the mariadb substring function docs explain string slicing
The native function takes a source text value and returns a smaller piece. You tell the database where to start counting characters in that text string. A positive start number counts forward from the left side of the text. A negative start number counts backward from the right end of the text. If you pass zero as the start point, the database returns an empty string.
You can also pass a length number to stop reading after several characters. If you leave the length out, the function reads until the text ends. Database admins often put this logic inside custom SQL views for support teams. The view slices out the first part of national IDs or card numbers. Analysts then query the view to check the last four digits for a user.
How teams use string functions to format sensitive columns
Support teams and data apps need small pieces of text to do daily work. A billing app might read the area code from a stored phone number. An analyst might pull the domain name from a list of user emails. Writing string slicing logic into a query keeps the result set clean and small.
Teams also build database views with string functions to limit what users see. They grant the support role permission to read the view instead of the table. This native setup works well when users only run pre-built reports in one app. It gives the database admin basic control over static query output at rest.
Serverless Function Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native string slicing leaves open in live sessions
Database roles and views decide who can log in and which objects they read. They do not inspect or control what individual queries do in flight. Engineers who debug live issues rarely stick to restricted read-only views for long. They often need direct table access to check indexes, joins, and slow queries.
Once an engineer has table read rights, string functions become optional for them. They do not have to slice emails or card numbers in their ad-hoc queries. A simple select statement pulls the whole column back to their local screen. Also, if a developer makes an off-by-one math mistake, the query returns private digits. Native permissions cannot rewrite sensitive fields in results when someone queries a raw table.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev is an open-source proxy that runs as a sidecar for your MySQL. It reads plain queries, prepared statements, and cursors on the wire.
First, hoop.dev guardrails block banned actions before MySQL runs them. An AI Analyzer you configure can score intent, and hoop.dev data masking rewrites sensitive string columns in results. Every query and verdict goes to the resource audit trail. Find the open-source binary on GitHub.
Frequently asked questions
How does the function handle negative starting positions?
A negative start value counts backward from the very end of the text string. This lets you grab the last four digits of a variable length string.
What happens if the length value is zero or negative?
If you provide a length of zero or less, the function returns an empty string. You must pass a positive length value to get characters back from the query.
Can string slicing in a view replace data masking for engineers?
Views only limit users who have no direct read rights on the base tables. Engineers with base table permissions can bypass the view unless masking rewrites matched fields in results.
Related guides
In this post