# `NewId2` (function)

> 生成27位纯数字的ID 模仿后台Java代码生成


- **Type:** FUNCTION
- **Returns:** `varchar(32)`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `NewId2`'`._

## Narrative

**Business context:** Variant id-generator that swaps the random and timestamp halves of `newId` — emits `'1' + 8-digit-rand + 9-digit-rand + 14-char-timestamp`, so the leading digits are random rather than the current date. Header is copy-pasted from `newId` and is again wrong about the length (the body produces 32 chars, not 27).

**What it does:** returns `CONCAT('1', CEILING(RAND()*9e7+1e7), CEILING(RAND()*9e8+1e8), DATE_FORMAT(NOW(),'%Y%m%d%H%i%s'))` — 1 + 8 + 9 + 14 = 32 numeric chars.

**Invocation:** Status: appears orphaned. No caller found in any channel (form-master, gdsmodule hooks, other routines, xly-src grep). Live id generation flows through `newId` (137 callers). Likely a variant developers prototyped but never adopted — candidate for maintainer audit / deletion.
