Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In the last video, we learned how to create a database, delete a database and create a table using
the Create Table SQL Command.
But this understanding in mind.
Let us now look at how data is added inside the customer table that we created in the last video.
Addition of data in tables is done using the insert into common.
And the syntax for this command is as follows.
Relate in certain to then the table name.
Then within the bracket we may specify the name of the columns.
Specifying column names is optional.
Next comes the key word values, after which we specify the values to be inserted in the record.
Now, if the column names are not specified, the values will be entered in the order of columns.
If I go to my table in pkg admin and see the columns, I open the table.
Here within the table, customer table.
If I open up the columns part, you can see customer ID, first name, last name, age, email ID.
This is the order of columns.
If the values we are entering have some missing attribute.
For example, if there is age or last name missing, then we need to specify the column names after
table name.
All of the values are in different order.
We will need to specify the column names in that particular order.
So let us look at the examples of insert into command.
If you want to insert a single row without mentioning the column names, this is how we do it.
We write insert into table name, which is customer table, and then the values which will have customer
ID, first name, last name, age and email ID of that particular customer.
Now let us go to PG Admin and run this SQL command.
This is my SQL query tool.
I'll start typing insert into.
Customer table.
Then values.
And after that, this will be the customer ID, which is one as this is the first record.
Then the first name, which is B BW.
And note that for strings you need to input the data within single codes.
For numeric integers.
You do not need to do the same thing.
And then the lady would just be.
See at the rate X, y, or Z dot com.
Now select this query and run it.
You can either press F5 or this run query button.
Grady returned successfully, so it was successful.
Now to check whether this command actually added this particular record in our table.
Go to our table.
Right.
Click on it.
Click on View, edit and select all roles.
Below you can see this is how our table is right now looking.
It has one record and that is exactly what we inserted into this table.
In the window above this result, you can see it is running a select command to get this result.
We'll be discussing the select command later.
For now we just use the graphical interface which PD admin provided us to see the table.
Let's go back to the presentation where we'll look at the second example.
And this is a good example.
Suppose the next entry.
We do not have the customer's last name.
Now, if we do not mention the column names, each of the customer will then be filled in the last name.
As that particular field of last name was missing in that record.
To avoid this error, we need to mention the column names after the table name.
So in this example, you can see.
The customer D does not have any last name, so we mentioned the customer ID first name.
Age and email ID as the columns in which values to be filled.
And then we give the values.
So now let's toggle back to admin and run this query also.
Insert into customer table.
Space.
Remember to put brackets and write the column names.
Custody first name.
Then age.
And then email.
We deliberately missed out on the last name.
After this, we values and then mention the Ford values, which will be customer ID of two.
Name is the.
It.
It's 23 and email ID is the at the rate x, y, z dot com.
And on this, a five.
This also was executed successfully.
Go to the table.
Right click view.
Ruth.
You can see for last name, the value is null.
In the last lecture we also discussed there is a constraint called normal.
Had there been a constraint on last name of it being not null, then this particular query would have
given us an error.
Now let's go back to our example and learn how to insert more than one record at the same time with
just one query.
So about two example showed how to add a single row to add multiple rows at the same time.
We just need to list down all the records separated by a comma, this comma.
It is important to remember this common.
Let us go and write this also in dpkg admin window.
You know this index.
Try to beat me typing this query insert into customer table values.
So this is the first record.
With 83 name.
E.
So if.
Age 27.
Email IDF.
The Red x Weather.com.
Goma.
Next entry for Coma G.
Last name H.
Age.
35.
G.
H.
X.
Y.
Z dot com.
And with the semicolon, select this query and run it.
So let us go back and check the data in our table.
It seems.
Got it exactly as we expected.
So did you beat me?
If you did, you are simply awesome at learning this.
Otherwise better next time.
Hold on.
There is another way to add data to tables.
Sometimes the data we want to have in the table is to be imported from a text file or a CSV file.
You may encounter this situation less number of times, but nevertheless it is important to know.
So we'll be learning how to copy a data from a file into a table using the copy command in the next
video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.