在当前数据库中,我有NUBMER(16)的列,但是由于事务大小增加到17个字符,我计划将其设为NUMBER,它支持32个char数字。
由于尺寸和性能明智,我想知道它对数据库的影响如何?
答案 0 :(得分:1)
Oracle数据库以可变长度格式存储数字数据。每 值以科学记数法存储,用1个字节存储 指数。数据库最多使用20个字节来存储尾数, 这是包含它的浮点数的一部分 有效数字。 Oracle数据库不存储前导和 尾随零。
因此,存储取决于实际数值而不仅仅是精度。
精确是有效位数。
要查看存储空间,请使用 import java.io.*;
public class SerializeDemo
{
public static void main(String [] args)
{
Employee e = new Employee();
e.name = "Reyan Ali";
e.address = "Phokka Kuan, Ambehta Peer";
e.SSN = 11122333;
e.number = 101;
try
{
FileOutputStream fileOut =
new FileOutputStream("/tmp/employee.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(e);
out.close();
fileOut.close();
System.out.printf("Serialized data is saved in /tmp/employee.ser");
}catch(IOException i)
{
i.printStackTrace();
}
}
}
import java.io.*;
public class DeserializeDemo
{
public static void main(String [] args)
{
Employee e = null;
try
{
FileInputStream fileIn = new FileInputStream("/tmp/employee.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
e = (Employee) in.readObject();
in.close();
fileIn.close();
}catch(IOException i)
{
i.printStackTrace();
return;
}catch(ClassNotFoundException c)
{
System.out.println("Employee class not found");
c.printStackTrace();
return;
}
System.out.println("Deserialized Employee...");
System.out.println("Name: " + e.name);
System.out.println("Address: " + e.address);
System.out.println("SSN: " + e.SSN);
System.out.println("Number: " + e.number);
}
}
和vsize
。
例如,
dump
让我们检查尺寸:
SQL> CREATE TABLE t (val NUMBER(16));
Table created.
SQL> INSERT INTO t VALUES (-12);
1 row created.
SQL> INSERT INTO t VALUES (1);
1 row created.
SQL> INSERT INTO t VALUES (12);
1 row created.
SQL> INSERT INTO t VALUES (1234);
1 row created.
SQL> INSERT INTO t VALUES (12345);
1 row created.
SQL> INSERT INTO t VALUES (123456789012345);
1 row created.
SQL> COMMIT;
Commit complete.