sql中對字串的操作

2021-10-01 03:41:19 字數 599 閱讀 9118

select length('moony--極上通氣系列s/m/l/xl '), char_length('moony--極上通氣系列s/m/l/xl ');

select length('moony--極上通氣系列s/m/l/xl '), char_length('moony--極上通氣系列s/m/l/xl ');

select length('w'), char_length('w');

select length('1');

length:獲取位元組長度,在utf-8編碼中,中文位元組長度為3,在gbk編碼中,中文位元組長度為2。

char_length:獲取字元長度。

參考文章:  sql中文字的長度

update

public.user

set 

story=

left(#,128),

where id = #

將字串中超過的長度去除:

參考文章:

C 中對字串的操作

一 靜態字串string操作 1 compareto string str 比較兩個字串,從第一位字元開始依次比較。返回值為1 0 1 2 indexof string substring 返回子串在父串中第一次出現的起始索引 索引從0開始 3 join string separator,strin...

SQL 操作字串

sql操作字串相對來說比較難一點,現在總結幾個常用的sql 對字串的操作 declare dd nvarchar 12 set dd 2015 03 13 print dd declare cc nvarchar 12 替換指定字元 set cc replace cast dd as nvarcha...

python中對字串操作總結

str1 hello world,hello,my name is richard print str1 去除首尾所有空格 print str1.strip 去除首部所有空格 print str1.lstrip 去除尾部所有空格 print str1.rstrip 也可以去掉一些特殊符號 print...