Oracle数据库分区表操作方法MySQL管理员应该知道如何通过指定哪些用户可连接到服务器、从哪里进行连接,以及在连接时做什么,来设置MySQL用户账号。MySQL3.22.11引入了两个更容易进行这项工作的语句:GRANT 语句创建MySQL用户并指定其权限,REVOKE 语句删除权限。这两个语句充当mysql数据库中的授权表的前端,并提供直接操纵这些表内容的可选择的方法。GRANT 和REVOKE 语句影响以下四个表: 授权表 内容 当您为某个用户发布GRANT 语句时,应在user表中为该用户创建一个项。如果该语句指定了所有全局特权(管理权限或用于所有数据库的权限),则这些指定也被记录在user表中。如果指定了数据库、表或列的权限,它们将记录在db、tables_priv 和columns_priv表中。 创建新用户和授权 GRANT 语句的语法如下: GRANT privileges (columns) ON what TO user IDENTIFIEDBY "password" WITH GRANT OPTION 要使用该语句,需要填写以下部分: privileges 分配给用户的权限。下表列出了可在GRANT 语句中使用的权限说明符: 权限说明符权限允许的操作 以下为引用的内容: | SQL> create table dinya_test 2 ( 3 transaction_id number primary key, 4 item_id number(8) not null, 5 item_description varchar2(300), 6 transaction_date date not null 7 ) 8 partition by range (transaction_id) 9 ( 10 partition part_01 values less than(30000000) tablespace dinya_space01, 11 partition part_02 values less than(60000000) tablespace dinya_space02, 12 partition part_03 values less than(maxvalue) tablespace dinya_space03 13 ); Table created. |
| 以下为引用的内容: SQL> create table dinya_test 2 ( 3 transaction_id number primary key, 4 item_id number(8) not null, 5 item_description varchar2(300), 6 transaction_date date not null 7 ) 8 partition by range (transaction_date) 9 ( 10 partition part_01 values less than(to_date(’2006-01-01’,’yyyy-mm-dd’)) tablespace dinya_space01, 11 partition part_02 values less than(to_date(’2010-01-01’,’yyyy-mm-dd’)) tablespace dinya_space02, 12 partition part_03 values less than(maxvalue) tablespace dinya_space03 13 ); Table created. |
这样我们就分别建了以交易序号和交易日期来分区的分区表。每次插入数据的时候,系统将根据指定的字段的值来自动将记录存储到制定的分区(表空间)中。
当然,我们还可以根据需求,使用两个字段的范围分布来分区,如partition by range ( transaction_id ,transaction_date), 分区条件中的值也做相应的改变,请读者自行测试。