- 工信部备案号 滇ICP备05000110号-1
- 滇公安备案 滇53010302000111
- 增值电信业务经营许可证 B1.B2-20181647、滇B1.B2-20190004
- 云南互联网协会理事单位
- 安全联盟认证网站身份V标记
- 域名注册服务机构许可:滇D3-20230001
- 代理域名注册服务机构:新网数码
--例:创建表名为table1,列名为column1,column2,…,数据类型为特定数据类型的表
Create table table1(
Column1 datetype,
Column2 datetype,
……
);
--添加字段:在已经建好的表table1中添加字段columnX,字符类型为number
Alter table table1
add columnX number;
--修改字段数据类型:修改columnX的数据类型为date
Alter table table1
Modify columnX date;
--修改字段名:修改columnX的名称为columnY
Alter table table1
Rename column columnX to columnY;
--删除字段:删除字段columnY
Alter table table1
Drop column columnY
--修改表名:修改表table1的名称为table2
Rename table1 to table2;
--删除表:删除表table2:
Drop table table2;
2.表中的数据管理
添加数据:在表table2中添加数据
注:往表中添加数据时,字段数量与值得数量需一直并且一一按顺序匹配,添加的数据类型要符合表字段的数据类型
Insert into table2(column1,column2,……)
Values(value1,value2,……);
添加字段默认数据:为表中某字段添加默认值,添加默认值后如果在插入一行数据时该字段没有设定插入的值,则自动填入默认值。
--第一种方法:在创建表时添加column1的默认值为0
Create table table1 (
Column1 number default 0;
Column2 datetype;
……
);
--第二种方法:创建好表后修改column的默认值为0
Create table table1 (
Column1 number;
Column2 datetype;
……
);
Alter table table1
Modify column1 default 0;
复制表数据:将table2中的数据复制到table1中
第一种方法:建表时复制,此时新建的table1与table2表结构相同
Create table table1
As
Select * from table2
注:可加入where字句限制限定插入数据
注:如只需要复制表结构而不需要数据,则加一不成立的条件即可:
Create table table1
As
Select * from table2
Where 1=2;
第二种方法:建表后复制,复制table2中的column11,column12两列数据至table1的column1,column2两列中
Insert into table1(column1,column2)
Select column11,column12 from table2
注:可加入where字句限制限定插入数据
修改表数据:修改表table1中column1的数据为value2
Update table1
Set column1=value2;
注:可加入where字句限制限定修改数据
删除数据:
第一种方法:有条件删除
Delete from table1
Where ……;
第二种方法:全部删除,删除table1中所有数据(不可回滚)
Truncate table table1
售前咨询
售后咨询
备案咨询
二维码
TOP