跳至主要內容

[mysql] CRUD sql

建立使用者
create user username identified by ‘password’;
授予權限
GRANT type_of_permission ON database_name.table_name TO ‘username’@’hostname’;
GRANT ALL PRIVILEGES ON *.* TO ‘mike’@’%’;
grant all privileges on database.* to ‘username’@’%’ identified by ‘password’;
FLUSH PRIVILEGES;
建資料表
CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;
建立多欄位索引 (Multiple-Column Index)
CREATE INDEX index_name ON table_name (column_name1, column_name2…);
什麼時候建立多欄位索引比較合適?如果您常對一張資料表查詢 WHERE column_name1=’xxx’ AND column_name2=’yyy’,這時你就可以對 column_name1 及 column_name2 這兩個欄位建立一個共同索引。
DROP INDEX 敘述句 (SQL DROP INDEX Statement)
我們要怎麼將索引移除掉?就是使用 DROP INDEX。
MySQL
ALTER TABLE table_name DROP INDEX index_name;
SQL Server
DROP INDEX table_name.index_name;
Oracle
DROP INDEX index_name;
MS Access
DROP INDEX index_name ON table_name;
reference: https://dba.stackexchange.com/questions/76788/create-a-database-with-charset-utf-8/76789
reference: https://www.fooish.com/sql/create-index-drop-index.html

分類:mysql
由 Compete Themes 設計的 Author 佈景主題