← Back to PostgreSQL Course | Chapter 5: Filtering & Functions | Lesson 1 of 7

String के Functions (UPPER LOWER LENGTH)

String functions text transform और inspect करते हैं।
Syntax
sql
SELECT UPPER(column), LOWER(column), LENGTH(column), SUBSTR(column, start, length)
FROM table_name;

String Functions (UPPER LOWER LENGTH)

UPPER और LOWER case बदलते हैं, LENGTH characters count करता है, SUBSTR (या SUBSTRING) string का हिस्सा extract करता है, TRIM surrounding spaces remove करता है, REPLACE text swap करता है, और || strings जोड़ता है।

PostgreSQL INITCAP, LEFT, RIGHT, SPLIT_PART, और CONCAT_WS जैसे और कई add करता है। Example portable functions इस्तेमाल करता है।

Note: PostgreSQL का INITCAP हर word capitalise करता है।

उदाहरण: String functions (UPPER LOWER LENGTH)

sql
CREATE TABLE people (id INTEGER PRIMARY KEY, first TEXT, last TEXT);
INSERT INTO people VALUES (1, '  ada ', 'LOVELACE'), (2, 'alan', 'Turing');
SELECT UPPER(TRIM(first)) AS first_up, LOWER(last) AS last_low FROM people;
SELECT LENGTH(last) AS len, SUBSTR(last, 1, 3) AS first3 FROM people;
SELECT TRIM(first) || ' ' || last AS full_name FROM people;
SELECT REPLACE(last, 'ing', 'ONG') AS replaced FROM people;

-- Output:
-- first_up | last_low
-- ADA | lovelace
-- ALAN | turing
-- len | first3
-- 8 | LOV
-- 6 | Tur
-- full_name
-- ada LOVELACE
-- alan Turing
-- replaced
-- LOVELACE
-- TurONG
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. strings जोड़ने के लिए + इस्तेमाल करना
  2. यह भूल जाना कि SUBSTR में strings 1-indexed हैं
  3. indexed columns पर functions apply करना और index use खोना
चैप्टर सारांश
  • UPPER, LOWER, LENGTH jaise functions मिलते हैं
  • SUBSTR extract करता है, TRIM clean करता है
  • REPLACE text swap करता है
  • || concatenate करता है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.