Hi Guys, I had been working in mssql and i am new to oracle.
i am creating a table of three columns
firstname | lastname | fullname
ramesh | kumar | ramesh kumar
what i want is to create a table and an automated column. for example, after we insert values in firstname and lastname columns, it wll combine data from both the columns and put that into the third column. firstname - rajesh. lastname - kumar. fullname - rajesh kumar.
Check out the syntax i use for creating this kind of table in mssql.
First: in SQL, string concatenation is done using the || operator.
So you would need to use firstname || lastname, not firstname + lastname
But most probably you want: firstname ||' '|| lastname to get a space between the two values.
Secondly: first rule of a relational database: do not store values that can be calculated by the existing data - especially in this case.
If you need the full name in a query, just query for it:
SELECT firstname ||' '|| lastname as fullname
If you don't want to write that every time, create a view that returns the information.
Third: You don't want char(20), you want varchar(20).