三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数

oracle

1.创建表

CREATE TABLE "YZH2_ORACLE" (
  "VARCHAR2_COLUMN" VARCHAR2(20) NOT NULL ENABLE,
  "NUMBER_COLUMN" NUMBER,
  "DATE_COLUMN" DATE,
  "CLOB_COLUMN" CLOB,
  "BLOB_COLUMN" BLOB,
  "BINARY_DOUBLE_COLUMN" BINARY_DOUBLE,
  "BINARY_FLOAT_COLUMN" BINARY_FLOAT,
  "CHAR_COLUMN" CHAR(1),
  "CHAR_VARYING_COLUMN" VARCHAR2(20),
  "DEC_COLUMN" NUMBER(*, 0),
  "DECIMAL_COLUMN" NUMBER(*, 0),
  "DOUBLE_PRECISION_COLUMN" FLOAT(126),
  "CHARACTER_COLUMN" CHAR(1),
  "CHARACTER_VARYING_COLUMN" VARCHAR2(20),
  "FLOAT_COLUMN" FLOAT(126),
  "INT_COLUMN" NUMBER(*, 0),
  "INTEGER_COLUMN" NUMBER(*, 0),
  "NATIONAL_CHAR_COLUMN" NCHAR(1),
  "NATIONAL_CHAR_VARYING_COLUMN" NVARCHAR2(20),
  "NATIONAL_CHARACTER_COLUMN" NCHAR(1),
  "NATIONAL_CHARACTER_VARY_COLUMN" NVARCHAR2(20),
  "NCHAR_COLUMN" NCHAR(1),
  "NCHAR_VARYING_COLUMN" NVARCHAR2(20),
  "NCLOB_COLUMN" NCLOB,
  "NUMERIC_COLUMN" NUMBER(*, 0),
  "NVARCHAR2_COLUMN" NVARCHAR2(20),
  "RAW_COLUMN" RAW(20),
  "REAL_COLUMN" FLOAT(63),
  "SMALLINT_COLUMN" NUMBER(*, 0),
  "TIMESTAMP_COLUMN" TIMESTAMP (6),
  "VARCHAR_COLUMN" VARCHAR2(20)
  )

三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第1张图片

预设游标10000(必要时)

alter system set open_cursors = 10000;

 模拟新增10万条数据




DECLARE I number := 0; 
BEGIN 
  FOR I IN 0..100000 LOOP 
    INSERT INTO YZH2_ORACLE (
        VARCHAR2_COLUMN, NUMBER_COLUMN, BINARY_DOUBLE_COLUMN,
      BINARY_FLOAT_COLUMN, CHAR_VARYING_COLUMN,
      DEC_COLUMN, DECIMAL_COLUMN, DOUBLE_PRECISION_COLUMN,
      CHARACTER_VARYING_COLUMN, FLOAT_COLUMN,
      INT_COLUMN, INTEGER_COLUMN, NATIONAL_CHAR_VARYING_COLUMN,
      NATIONAL_CHARACTER_VARY_COLUMN,
      NCHAR_VARYING_COLUMN, NUMERIC_COLUMN,
      NVARCHAR2_COLUMN, REAL_COLUMN, SMALLINT_COLUMN,
      VARCHAR_COLUMN
    )
    VALUES (I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,I, I, I, I); 
  END LOOP; 
  COMMIT; 
END;

三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第2张图片

 三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第3张图片

 1.1 oracle一条sql数据生成100万条数据

SELECT
	rownum AS id,
	to_char(sysdate + rownum / 24 / 3600, 'yyyy-mm-dd hh24:mi:ss') AS inc_datetime,
	trunc(dbms_random.value(0, 100)) AS random_id,
	dbms_random.string('x',20) AS random_string
FROM
	dual
CONNECT BY
	LEVEL <= 1000000;  #可传参数

 三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第4张图片

三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第5张图片 

三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第6张图片

 

 

2.SQL SERVER

 

创建测试表


CREATE TABLE dbo.yzh2_ms_checker (
  BIGINT_COLUMN bigint NULL DEFAULT (NULL),
  BINARY_COLUMN binary(64) NULL DEFAULT (NULL),
  BIT_COLUMN bit NULL DEFAULT (NULL),
  CHAR_COLUMN char(64) NULL DEFAULT (NULL),
  CHAR_MAX_COLUMN char(128) NULL DEFAULT (NULL),
  DATE_COLUMN date NULL DEFAULT (NULL),
  DATETIME_COLUMN datetime NULL DEFAULT (NULL),
  DECIMAL_COLUMN decimal(18,0) NULL DEFAULT (NULL),
  FLOAT_COLUMN real NULL DEFAULT (NULL),
  INT_COLUMN int NULL DEFAULT (NULL),
  MONEY_COLUMN money NULL DEFAULT (NULL),
  NCHAR_COLUMN nchar(64) NULL DEFAULT (NULL),
  NCHAR_MAX_COLUMN nchar(128) NULL DEFAULT (NULL),
  NTEXT_COLUMN ntext NULL DEFAULT (NULL),
  NUMERIC_COLUMN numeric(18,0) NULL DEFAULT (NULL),
  NVARCHAR_COLUMN nvarchar(64) NULL DEFAULT (NULL),
  NVARCHAR_MAX_COLUMN nvarchar(128) NULL DEFAULT (NULL),
  REAL_COLUMN real NULL DEFAULT (NULL),
  SMALLINT_COLUMN smallint NULL DEFAULT (NULL),
  SMALLMONEY_COLUMN smallmoney NULL DEFAULT (NULL),
  TEXT_COLUMN text NULL DEFAULT (NULL),
  TINYINT_COLUMN tinyint NULL DEFAULT (NULL),
  VARBINARY_COLUMN varbinary(64) NULL DEFAULT (NULL),
  VARCHAR_COLUMN varchar(64) NULL DEFAULT (NULL),
  VARCHAR_MAX_COLUMN varchar(128) NULL DEFAULT (NULL),
  XML_COLUMN xml NULL DEFAULT (NULL)
);
GO

三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第7张图片


DECLARE @i INT
SET
    @i = 1 
WHILE @i <=30000 BEGIN

INSERT INTO dbo.yzh2_ms_checker (
    BIGINT_COLUMN, BINARY_COLUMN, BIT_COLUMN,
    CHAR_COLUMN, CHAR_MAX_COLUMN, DATE_COLUMN,
    DATETIME_COLUMN, DECIMAL_COLUMN,
    FLOAT_COLUMN, INT_COLUMN, MONEY_COLUMN,
    NCHAR_COLUMN, NCHAR_MAX_COLUMN,
    NTEXT_COLUMN, NUMERIC_COLUMN, NVARCHAR_COLUMN,
    NVARCHAR_MAX_COLUMN, REAL_COLUMN,
    SMALLINT_COLUMN, SMALLMONEY_COLUMN,
    TEXT_COLUMN, TINYINT_COLUMN, VARBINARY_COLUMN,
    VARCHAR_COLUMN, VARCHAR_MAX_COLUMN,
    XML_COLUMN
  )
VALUES
  (
    @i,1,@i,@i,@i,GETDATE(),GETDATE(),@i,@i,@i,@i,@i,@i,STR(@i),
    @i,STR(@i),STR(@i),@i,@i,@i,STR(@i),NULL,1,@i,@i,STR(@i)
  )

SET @i = @i + 1 
END;

三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第8张图片

三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第9张图片

3.MySQL

创建测试表

CREATE TABLE `yzh2_sync` (
  `bigint_column` bigint(10) NOT NULL  AUTO_INCREMENT COMMENT '1',
  `bit_column` bigint(10) NOT NULL COMMENT '2',
  `blob_column` blob NOT NULL COMMENT '3',
  `char_column` char(64) NOT NULL COMMENT '4',
  `date_column` date NOT NULL COMMENT '5',
  `datetime_column` datetime NOT NULL COMMENT '6',
  `decimal_column` decimal(18,9) NOT NULL COMMENT '7',
  `double_column` double NOT NULL COMMENT '8',
  `float_column` float NOT NULL COMMENT '10',
  `int_column` int(11) NOT NULL COMMENT '11',
  `longblob_column` longblob NOT NULL COMMENT '12',
  `longtext_column` longtext NOT NULL COMMENT '13',
  `mediumblob_column` mediumblob NOT NULL COMMENT '14',
  `mediumint_column` mediumint(9) NOT NULL COMMENT '15',
  `mediumtext_column` mediumtext NOT NULL COMMENT '16',
  `smallint_column` smallint(6) NOT NULL COMMENT '18',
  `text_column` text NOT NULL COMMENT '19',
  `time_column` time NOT NULL COMMENT '20',
  `timestamp_column` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '21',
  `tinyint_column`  int(11)  NOT NULL COMMENT '22',
  `tinytext_column` tinytext NOT NULL COMMENT '23',
  `varchar_column` varchar(32) NOT NULL COMMENT '24',
  PRIMARY KEY (`bigint_column`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


模拟新增3万条数据



DROP PROCEDURE if EXISTS test_insert;
DELIMITER //
CREATE PROCEDURE test_insert()
  BEGIN
  DECLARE y BIGINT DEFAULT 0;
  WHILE y<30000
  DO

    INSERT INTO yzh2_sync (
      bit_column, blob_column, char_column,
      date_column, datetime_column, decimal_column,
      double_column, float_column, int_column,
      longblob_column, longtext_column,
      mediumblob_column, mediumint_column,
      mediumtext_column, smallint_column,
      text_column, time_column, timestamp_column,
      tinyint_column, tinytext_column,
      varchar_column)
    VALUES(
      y, y, y, 
      now(), now(), y, 
      y, y, y, 
      y, y, 
      y, y, 
      y, y, 
      y,now(), now(), 
      y, y, 
      y
    );

    SET y=y+1;
  END WHILE ;
  commit;
END //

三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第10张图片

{ CALL xag.test_insert() }

三个主流数据库(Oracle、MySQL和SQL Server)的“单表造数_第11张图片

你可能感兴趣的:(oracle,数据库)