mysql大小問題

2021-07-24 20:24:21 字數 1604 閱讀 9967

大小寫有關的引數介紹:

lower_case_file_system

該引數是用於描述data目錄所在的作業系統是否為大小寫敏感,該引數為bool型別,但無法修改。

0 -- 大小寫敏感 

1 -- 大小寫不敏感

在linux上的都是off或者0,在windows下是on或者0。

0 -- 大小寫敏感。(unix,linux預設)

表名儲存為給定的大小和比較是區分大小寫的 。

建立的庫表將原樣儲存在磁碟上;sql語句也會原樣解析。

在大小寫不敏感的系統上將出錯,比如windows

1 -- 大小寫不敏感。(windows預設)

表名儲存在磁碟是小寫的,但是比較的時候是不區分大小寫。

建立的庫表時,mysql將所有的庫表名轉換成小寫儲存在磁碟上;sql語句同樣會將庫表名轉換成小寫。

如需要查詢以前建立的test_table(生成test_table.frm檔案),即便執行select * from test_table,也會被轉換成select * from test_table,致使報錯表不存在。

2 -- 大小寫不敏感(os x預設)

建立的庫表將原樣儲存在磁碟上。但sql語句將庫表名轉換成小寫

另外,如果在windows平台下,預設為1,也就是建立表不管怎麼大小寫組合,儲存、顯示、查詢都是先轉為小寫執行;如果設定為2,則底層儲存的***.frm

中***和一些編輯器是跟建立時,***.ibd是轉為小寫,大小寫查詢無影響

linux平台如果大小寫不敏感,可以設定lower_case_table_names為1

lower_case_table_names這個引數設定完需要重啟

如果之前的跟現在不一樣,需要提前批量修改下大小寫,或者匯入匯出

select -- t2.table_schema,t2.table_name,t2.column_name,upper(t2.column_name),t2.column_type,

-- case when t2.is_nullable='no' then 'not null' else 'null' end as isnull1,t2.column_comment,

concat('alter table ',t2.table_schema,'.',t2.table_name,' change ',' \`',t2.column_name,'\` \`',upper(t2.column_name),'\` ',

t2.column_type,' ',case when t2.is_nullable='no' then 'not null' else 'null' end,' comment ''',t2.column_comment,''';') as c

from information_schema.tables t1, information_schema.columns t2

where t1.table_schema = 'db1'

and t1.table_type = 'base table'

and t1.table_schema = t2.table_schema

and t1.table_name = t2.table_name

UNION大小問題

聯合體 union 當多個資料需要共享記憶體或者多個資料每次只取其一時,可以利用聯合體 union 1 聯合體是乙個結構 2 它的所有成員相對於基位址的偏移量都為0 3 此結構空間要大到足夠容納最 寬 的成員 4 其對齊方式要適合其中所有的成員 下面舉例說明 如聯合體 1 union u 2 s佔9...

mysql中datetime比較大小問題

select sum studychj as tofflinejz from afterline where checkflag 1 and studytype 1 and studybegin 2010 01 01 00 00 00 and studyend 2010 12 01 00 00 00...

mysql中datetime比較大小問題

select sum studychj as tofflinejz from afterline where checkflag 1 and studytype 1 and studybegin 2010 01 01 00 00 00 and studyend 2010 12 01 00 00 00...