古詩詞大全網 - 成語經典 - sql常用語句格式及例子說明是什麽呢?

sql常用語句格式及例子說明是什麽呢?

如下:

1、創建表:Create table 表名 ( s_id number(4) ,? s_name varchar2(10) , s_sex char(2) );

2、刪除表:Drop table 表名;

3、重命名表名:Rename 舊表名 to 新表名 ;

4、添加列:Alter table 表名 add (? s_age number(3) );

5、刪除列:Alter table 表名 drop( S_sex? );

6、查詢列表所有信息:Select * from 表名 ;

7、查詢壹個列表信息(加where條件):Select * from 表名 where s_id = 302。

sql創建後表的修改基礎用法

添加列 :基本形式:alter table 表名 add 列名 列數據類型 [after 插入位置]。

1、在表的最後追加列 address: alter table students add address char(60); 2、在名為 age 的列後插入列 birthday: alter table students add birthday date after age;

修改列 :基本形式:alter table 表名 change 列名稱 列新名稱 新數據類型;

1、將表 tel 列改名為 telphone: alter table students change tel telphone char(13) default "-";

2、將 name 列的數據類型改為 char(16): alter table students change name name char(16) not nul。