SQL: stores the value of datetime ticks in C #.

Source: Internet
Author: User
Datetime d = Convert. todatetime (system. datetime. Now. tostring ( " Yyyy-mm-dd " ));

LongLongbegin=D. ticks;
LongLongend=D. adddays (1). Addmilliseconds (-1). Ticks;

String SQL =   " Select * from TB where tricksfield between @ loginbegin and @ lengend " ;
Sqlcommand cmd =   New Sqlcommand ();
Cmd. Parameters. Add ( " @ Loginbegin " , Dbtype. int64, 64 );
Cmd. Parameters. Add ( " @ Loginend " , Dbtype. int64, 64 );
Cmd. Parameters [ 0 ]. Value = Longbegin;
Cmd. Parameters [ 1 ]. Value = Longend;

 

 

Find a million-level data table on the birthday of today,

Two parameters can be generated in C # and executed in a stored procedure or by passing a parameter statement. indexes can be created on ticksfield to Improve the efficiency.

//************************************** *
. NET Framework class library
Datetime. ticks attribute

The value of this attribute indicates that the time passed since midnight, January 1, January 1, 0001 is 100 milliseconds.

The number of intervals.

If SQL is used, use the front-endProgramObtain several data records.
C # code datetime d = convert. todatetime ("1900-1-1 ");
Datetime d1 = convert. todatetime ("0001-1-1 ");

Timespan T = D-D1;

Response. Write ("1900-1-1. ticks:" + D. ticks + "</BR> ");
Response. Write ("0001-1-1. ticks:" + d1.ticks + "</BR> ");
Response. Write (T. totalmilliseconds. tostring ());

 

 

 

First, create the logical model of the table structure:
Use the data warehouse modeling idea to create a star model:
1 fact table
Id Primary Key
Crrq_id date ID
Place_id location ID
Xname_id name ID
XX fact Field

2. Date dimension table
Crrq_id date ID
Crrq date

3. Location dimension table
Place_id location ID
Place location

4. Customer dimension table
Xname_id name ID
Xname

Using the physical Optimization Method of the DB2 database:
Fact tables
1. database partition
2 Table partitions
3. Create an MDC
4. Create an MQT
5. Create a bitmap index for the federated primary key

A table with 0.4 billion data entries can only be regarded as a small table in the data warehouse.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.