简体   繁体   中英

Adding a nvarchar(MAX) Column to my audit table

I have an audit table, where I added a Column named “ExtraInfo”, this column might store null value or it might contain for example all the usernames that have been assigned to a group; could be 100, 200 users. So I gave this column a Type of nvarchar(MAX), as in the future our AD users might get huger and I do not want to face issues regarding the column size. But I have the following concern:-

  1. Will SQL server 2008 R2 occupy only the bytes that the nvarchar(max) currently have , or it will occupy its full capacity even if the colum only contain 10 bytes or even it is null?

  2. Is there any disadvantages of using nvarch(max) inside an audit table I am not aware of ?

Thnaks

  1. It will occupy the capacity that is used, however behind the scenes it is converted to a text field which incurs extra overhead. Please see This for reference.
  2. As I noted in my comment if you ever need to do any searching against this field it is not recommended to store this type of data this way as it will lose performance as the table grows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM