1. OceanBase介绍

     OceanBase是蚂蚁金服研发的数据库,有Oracle和Mysql两种模式。

2.Oracle模式的遍历

  遍历表:

      select TABLE_NAME,NUM_ROWS from user_tables;
      OceanBase 数据库的表遍历

  遍历列:

select COLUMN_NAME, DATA_TYPE, DATA_LENGTH, NULLABLE 
    from user_tab_columns where table_name = 'TEST1';
    OceanBase 数据库的表遍历

3.Mysql模式的遍历

   

OB Mysql

1. 遍历数据库的表

show tables from $database

MySQL [test_db]> show tables from test_db;
+-------------------+
| Tables_in_test_db |
+-------------------+
| t1                |
+-------------------+
1 row in set (0.01 sec)

2. 获取数据表的列名称和类型

show columns from $database.$table

MySQL [test_db]> show columns from test_db.t1;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| c1    | int(11)      | NO   | PRI | NULL    |       |
| c2    | varchar(256) | YES  |     | NULL    |       |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

3. 读数据表中数据

直接用 sql 查表

 

相关文章: