實用sql語句

2021-07-15 13:07:18 字數 1191 閱讀 1743

1。 加許可權:

grant alter,create,select,insert,update,delete,index on recommend.* to [email protected] identified by "growth";

flush privileges;

alter table feed change  update_time update_time timestamp not null default current_timestamp on update current_timestamp;
3.    增加唯一性限制

alter table *** add constraint uk_1 unique (xx,***);
4.   檢視建立語句

show create table ***;
5.    增加聯合主鍵

alter table *** add primary key (xx,***);
6.   修改列

alter table *** change id id int(20) not null auto_increment;
7.  檢視索引資訊

show index from table***
8.  加入字段

alter table *** add column bbb int(11) not null default 0;
9.  插入如果重複 更新

insert into table (a,b,c) values (1,2,3) on duplicate key update c=c+1;
10.  新增索引

alter table *** add index `idx_bb`(`bb`);
11.  匯入本地資料到msyql

load data local infile '/tmp/mysql_user.csv' into table user fields terminated by ',' character set utf8;

實用SQL語句

1 將乙個表中的內容拷貝到另外乙個表中 insert intotestt1 a1 b1,c1 selecta,b cfromtest insert intotesttselect fromtest 前提是兩個表的結構完全相同 insert intonotebook id title content ...

oracle實用sql語句

檢視oracle 資料庫中本使用者下的所有表 select table name from user tables 檢視oracle 資料庫中所有使用者下的所有表 select user,table name from all tables 檢視oracle 資料庫中本使用者下的所有列 select...

SQL實用語句

sql實用語句 三 技巧 1 1 1,1 2的使用,在sql語句組合時用的較多 where 1 1 是表示選擇全部 where 1 2 全部不選,如 if strwhere begin set strsql select count as total from tblname where strwh...