Uno upload questions

Hi, I’m new to this, and sorry if this is a basic question.
If I have uploaded my sketch to the uno board from the ide program when I upload a second sketch does it delete the first sketch ?
Will the last sketch uploaded stay on the uno board when every thing is switched of and disconnected ?
If the above is yes, if I then connect a 9v battery to the uno board and no pc or laptop connection to ide. When I turn on the 9v power will the sketch run ? And if so will it start from the beginning each time ?
Sorry to be a pest and thanks in advance for your help
Cheers
Stan

Yes, Yes, Yes, Yes.

Everyone of us once started with the basic questions.

Yes, the uploading process deletes the previous sketch.

Yes, the sketch will stay on the board even if it has no power until you make another upload.

Yes, and yes. Each time you "start" the Uno, it will execute the commands of void setup() once and keep executing void loop() until you turn it off.

Thanks for your help

Be aware that a PP3 battery (example below) is not very suitable for use with the Uno.

image

You're better off using 6 x 1.5 batteries in a battery holder.

Is there a reason for this

This kind of battery hasn´t much current to provide and it will be drained quickly depending on your circuits load.
As an example, it last an afternoon in one of my projects that had a 16x2 LCD, temp&humidity sensor, SD card and a wind speed measuring system.

Thanks for that, will monitor how long it lasts