# Default value with constraint name

**URL:** <https://forum.liquibase.org/t/default-value-with-constraint-name/588>\
**Category:** General Discussion\
**Created:** [July 1, 2010, 8:43pm UTC](https://forum.liquibase.org/t/default-value-with-constraint-name/588 "2010-07-01T20:43:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wdickers](https://avatars.discourse-cdn.com/v4/letter/w/f9ae1b/32.png) [@wdickers](https://forum.liquibase.org/u/wdickers)\
**Post date:** [July 1, 2010, 8:43pm UTC](https://forum.liquibase.org/t/default-value-with-constraint-name/588/1 "2010-07-01T20:43:00Z")

</div>

I want to convert the following excerpt of a create table SQL script into Liquibase:

&nbsp; &nbsp;SuccessInd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char(1) &nbsp;NOT NULL  
&nbsp; &nbsp;CONSTRAINT DefALog\_SuccessInd DEFAULT &nbsp;‘N’

I want something along the lines of

 &nbsp; &nbsp; &nbsp; &nbsp; \<constraints &nbsp;uniqueConstraintName="DefALog\_SuccessInd" defaultValue="N /\> \</column\> \<p\>However, defaultValue must go into the column tag (and can you even have multiple constraints per column?). Is there any way to assign a constraint name to a default value?\</p\>

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [July 1, 2010, 8:43pm UTC](https://forum.liquibase.org/t/default-value-with-constraint-name/588/2 "2010-07-01T20:43:00Z")

</div>

I think you can just have one constraint block per column, but you can combine the two you have:

&nbsp; &nbsp; \<constraints&nbsp; nullable="false"&nbsp; uniqueConstraintName="DefALog\_SuccessInd" defaultValue="N /\> \</column\> \<p\>should do what you want.\</p\> \<p\>Nathan\</p\>

---

<div class="post-metadata">

**Author:** ![wdickers](https://avatars.discourse-cdn.com/v4/letter/w/f9ae1b/32.png) [@wdickers](https://forum.liquibase.org/u/wdickers)\
**Post date:** [July 1, 2010, 8:43pm UTC](https://forum.liquibase.org/t/default-value-with-constraint-name/588/3 "2010-07-01T20:43:00Z")

</div>

Hmm, still get the error that defaultValue is not allowed inside a constraint tag. I guess I have to use a for named default constrains

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [July 1, 2010, 8:43pm UTC](https://forum.liquibase.org/t/default-value-with-constraint-name/588/4 "2010-07-01T20:43:00Z")

</div>

What do you have for your xsd reference on the top of your xml file?&nbsp; uniqueConstraintName should be allowed in

Nathan

---

<div class="post-metadata">

**Author:** ![wdickers](https://avatars.discourse-cdn.com/v4/letter/w/f9ae1b/32.png) [@wdickers](https://forum.liquibase.org/u/wdickers)\
**Post date:** [July 1, 2010, 8:43pm UTC](https://forum.liquibase.org/t/default-value-with-constraint-name/588/5 "2010-07-01T20:43:00Z")

</div>

Still using 1.9  
\<databaseChangeLog xmlns=“[http://www.liquibase.org/xml/ns/dbchangelog/1.9”](http://www.liquibase.org/xml/ns/dbchangelog/1.9%22) xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance”](http://www.w3.org/2001/XMLSchema-instance%22) xsi:schemaLocation=“[http://www.liquibase.org/xml/ns/dbchangelog/1.9](http://www.liquibase.org/xml/ns/dbchangelog/1.9) [http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd”\>](http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd%22>)

uniqueConstraintName is allowed, but defaultValue has to go in the column tag.

&nbsp; &nbsp; 

Is allowed, however this way wouldn’t the constraint name be tied to nullability instead of the default value?

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [July 1, 2010, 8:43pm UTC](https://forum.liquibase.org/t/default-value-with-constraint-name/588/6 "2010-07-01T20:43:00Z")

</div>

Sorry, I get your question now.&nbsp; There isn’t a way to set the default constraint name at this point.&nbsp; The uniqueConstraintName is for if you set a unique constraint.&nbsp; If you want it named, you’ll have to use the tag.&nbsp; &nbsp; Any idea how many database types allow setting of default constraint names?&nbsp;

Nathan

---

<div class="post-metadata">

**Author:** ![wdickers](https://avatars.discourse-cdn.com/v4/letter/w/f9ae1b/32.png) [@wdickers](https://forum.liquibase.org/u/wdickers)\
**Post date:** [July 1, 2010, 8:43pm UTC](https://forum.liquibase.org/t/default-value-with-constraint-name/588/7 "2010-07-01T20:43:00Z")

</div>

Nope, no idea. Guess I was forgetting how many database types are served by liquibase. Thank you.  
In case a fellow newbie has the same problem, I used the following

&nbsp; &nbsp; ... &nbsp; &nbsp; ALTER TABLE ] ADD CONSTRAINT [constraint name] DEFAULT [value] for [column];

---

<div class="post-metadata">

**Author:** ![un64727609740297311r](https://avatars.discourse-cdn.com/v4/letter/u/76d3ee/32.png) [@un64727609740297311r](https://forum.liquibase.org/u/un64727609740297311r)\
**Post date:** [July 1, 2010, 8:43pm UTC](https://forum.liquibase.org/t/default-value-with-constraint-name/588/8 "2010-07-01T20:43:00Z")

</div>

Hi Nathan,

Is it now possible to set the default constraint name? I am using&nbsp; &nbsp;liquibase 3.6.3, generated db changelog which gives out the following

Attribute ‘defaultValueConstraintName’ is not allowed to appear in element ‘column’.
