常用的更改表字段的sql語句

2021-05-22 15:53:15 字數 1761 閱讀 5190

常用的sql語句

sql server 更改表結構:

//增加列:

alter   table   table2   add   name   char(8)

//刪除列:

alter   table   table2   drop   column   id

//重新命名列名稱

sp_rename 'tablename.[old_col]','new_col','column';

//改變列的資料型別

alter table tablename alter column nr varchar(4000);

//重新命名表名

sp_rename   'customers',   'custs' ; 

//連線字串

select  '11'+'22'+'33' from table;

mysql 更改表結構:

//增加乙個新列

alter table t2 add columnname varchar(50) not null default '0' comment '新列'; 

//刪除乙個列

alter table t2 drop column columnname;

//重新命名列

alter table t1 change a b integer;

//改變列的型別

alter table t1 change b b bigint not null;

//重新命名表

alter table t1 rename t2;

//加索引

alter table tablename add index idx_name(name); 

//刪除索引

alter table tablename drop index idx_name;

//連線字串

select concat(str1,str2,.....) from table;

//替換字段指定的值為新值

update tablename set column1=replace(colmun1,被替換字串,替換字串);

oracle更改表結構:

//增加乙個新列

alter table t2 add columnname varchar2(50) ; 

//刪除乙個列

alter table t2 drop column columnname;

//重新命名列

alter table tablename rename column src to dest;

//改變列的型別

alter table tablename modify col varchar2(255);

//重新命名表

alter table t1 rename to t2;

常用的juery

判斷js變數是否定義:

if(typeof(att_show_type)=="undefined") {

jquery顯示/隱藏乙個html標籤:

$("#id").hide();     $("#id").show();   

去jquery**的第一行內容:

$("#tablename tr:first").html();

清空標籤內容:

$("#tablename").empty();

MySQL常用的 表字段 SQL語句寫法總結

mysql常用的刪除表 建表 設定 修改編碼 增加列 字段 刪除列 字段 修改列 字段 新增索引 sql語句寫法,在mysql中我們對資料 表字段 的修改命令只要使用alter。具體如下 1.刪除表 如果存在 drop table if exists test 2.建表 create table t...

MySql的簡單修改表字段SQL語句

新增乙個字段,預設值為0,非空,自動增長,主鍵 alter table tabelname add new field name field type default 0 not null auto increment add primary key new field name 增加乙個新字段 a...

MySql的簡單修改表字段SQL語句

新增乙個字段,預設值為0,非空,自動增長,主鍵 alter table tabelname add new field name field type default 0 not null auto increment add primary key new field name 增加乙個新字段 a...